Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/c535c-2.f90

raw
1 ! PR 54753
2 ! { dg-do compile }
3 !
4 ! TS 29113
5 ! C535c If an assumed-size or nonallocatable nonpointer assumed-rank
6 ! array is an actual argument corresponding to a dummy argument that
7 ! is an INTENT(OUT) assumed-rank array, it shall not be [...]
8 ! finalizable [...].
9 !
10 ! This constraint is numbered C839 in the Fortran 2018 standard.
11 !
12 ! This test file contains tests that are expected to issue diagnostics
13 ! for invalid code.
14
15 module m
16
17 type :: t1
18 integer :: id
19 real :: xyz(3)
20 contains
21 final :: finalize_t1
22 end type
23
24 contains
25
26 subroutine finalize_t1 (obj)
27 type(t1) :: obj
28 end subroutine
29
30 subroutine s1 (x, y)
31 type(t1) :: x(..)
32 type(t1), intent(out) :: y(..)
33 end subroutine
34
35 ! This call should be OK as it does not involve assumed-size or
36 ! assumed-rank actual arguments.
37 subroutine test_known_size (a1, a2, n)
38 integer :: n
39 type(t1) :: a1(n,n), a2(n)
40
41 call s1 (a1, a2)
42 end subroutine
43
44 ! Calls with an assumed-size array argument should be rejected.
45 subroutine test_assumed_size (a1, a2)
46 type(t1) :: a1(*), a2(*)
47
48 call s1 (a1, a2) ! { dg-error "(A|a)ssumed.rank" }
49 end subroutine
50
51 ! This call should be OK.
52 subroutine test_assumed_rank_pointer (a1, a2)
53 type(t1), pointer :: a1(..), a2(..)
54
55 call s1 (a1, a2)
56 end subroutine
57
58 ! This call should be OK.
59 subroutine test_assumed_rank_allocatable (a1, a2)
60 type(t1), allocatable :: a1(..), a2(..)
61
62 call s1 (a1, a2)
63 end subroutine
64
65 ! The call should be rejected with a nonallocatable nonpointer
66 ! assumed-rank actual argument.
67 subroutine test_assumed_rank_plain (a1, a2)
68 type(t1) :: a1(..), a2(..)
69
70 call s1 (a1, a2) ! { dg-error "(A|a)ssumed.rank" }
71 end subroutine
72
73 end module
74