1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Tests valid and invalid ENTRY statements
5 !ERROR: ENTRY 'badentryinmodule' may appear only in a subroutine or function
8 module subroutine separate
13 entry entryinmodproc
! ok
15 !ERROR: ENTRY may not appear in an executable construct
16 entry badentryinblock
! C1571
19 !ERROR: ENTRY may not appear in an executable construct
20 entry ibadconstr() ! C1571
24 !ERROR: ENTRY may not appear in an internal subprogram
25 entry badentryininternal
! C1571
32 module procedure separate
33 !ERROR: ENTRY 'badentryinsmp' may not appear in a separate module procedure
34 entry badentryinsmp
! 1571
39 !ERROR: ENTRY 'badentryinprogram' may appear only in a subroutine or function
40 entry badentryinprogram
! C1571
44 !ERROR: ENTRY 'badentryinbd' may appear only in a subroutine or function
45 entry badentryinbd
! C1571
48 subroutine subr(goodarg1
)
49 real, intent(in
) :: goodarg1
51 !ERROR: A dummy argument may not also be a named constant
52 integer, parameter :: badarg1
= 1
57 !ERROR: A dummy argument must not be initialized
58 integer :: badarg5
= 2
59 entry okargs(goodarg1
, goodarg2
)
60 !ERROR: RESULT(br1) may appear only in a function
61 entry badresult() result(br1
) ! C1572
62 !ERROR: 'badarg2' is already declared in this scoping unit
63 !ERROR: 'badarg4' is already declared in this scoping unit
64 entry badargs(badarg1
,badarg2
,badarg3
,badarg4
,badarg5
)
74 double precision :: weird2
80 integer, allocatable
:: alloc
81 integer, pointer :: ptr
83 !ERROR: 'ibad1' is already declared in this scoping unit
84 entry ibad1() result(ibad1res
) ! C1570
85 !ERROR: 'ibad2' is already declared in this scoping unit
87 !ERROR: ENTRY in a function may not have an alternate return dummy argument
88 entry ibadalt(*) ! C1573
89 !ERROR: RESULT(ifunc) may not have the same name as the function
90 entry isameres() result(ifunc
) ! C1574
92 !ERROR: RESULT(iok) may not have the same name as an ENTRY in the function
93 entry isameres2() result(iok
) ! C1574
94 entry isameres3() result(iok2
) ! C1574
95 !ERROR: 'iok2' is already declared in this scoping unit
97 !These cases are all acceptably incompatible
98 entry iok3() result(weird1
)
99 entry iok4() result(weird2
)
100 entry iok5() result(weird3
)
101 entry iok6() result(weird4
)
102 !ERROR: Result of ENTRY is not compatible with result of containing function
103 entry ibadt1() result(weird5
)
104 !ERROR: Result of ENTRY is not compatible with result of containing function
105 entry ibadt2() result(weird6
)
106 !ERROR: Result of ENTRY is not compatible with result of containing function
107 entry ibadt3() result(iarr
)
108 !ERROR: Result of ENTRY is not compatible with result of containing function
109 entry ibadt4() result(alloc
)
110 !ERROR: Result of ENTRY is not compatible with result of containing function
111 entry ibadt5() result(ptr
)
112 !ERROR: Cannot call function 'isubr' like a subroutine
115 continue ! force transition to execution part
117 implicit = 666 ! ok, just ensure that it works
118 !ERROR: Cannot call function 'implicit' like a subroutine
122 function chfunc() result(chr
)
123 character(len
=1) :: chr
124 character(len
=2) :: chr1
125 !ERROR: Result of ENTRY is not compatible with result of containing function
126 entry chfunc1() result(chr1
)
130 !ERROR: 'subr' is already defined as a global identifier
132 !ERROR: 'ifunc' is already defined as a global identifier
134 !ERROR: 'm1' is already defined as a global identifier
136 !ERROR: 'iok1' is already defined as a global identifier
139 !ERROR: Cannot call subroutine 'iproc' like a function
140 !ERROR: Function result characteristics are not known
146 !ERROR: EXTERNAL attribute not allowed on 'm2entry2'
151 entry m2entry2
! NOT ok
159 subroutine simplesubr
162 procedure(simplesubr
), pointer :: p
171 module subroutine m3entry1
176 !ERROR: 'm3entry1' is already declared in this scoping unit
183 module procedure m4entry1
186 module procedure m4entry2
189 module procedure m4entry3
193 entry m4entry1
! in implicit part
195 entry m4entry2
! in specification part
197 entry m4entry3
! in executable part
205 !ERROR: No explicit type declared for 'implicitbad1'
207 inone
= 0 ! force transition to execution part
208 !ERROR: No explicit type declared for 'implicitbad2'
214 real function setBefore
222 recursive subroutine passSubr
228 recursive function passFunc1
229 !ERROR: Actual argument associated with procedure dummy argument 'e=' is not a procedure
231 !ERROR: Actual argument associated with procedure dummy argument 'e=' is not a procedure
234 !ERROR: Actual argument associated with procedure dummy argument 'e=' is not a procedure
237 recursive function passFunc2() result(res
)
240 entry ent3() result(res
)
248 !ERROR: 'q' appears more than once as a dummy argument name in this subprogram
250 !ERROR: Dummy argument 'x' may not be used before its ENTRY statement
253 !ERROR: 's7' may not appear as a dummy argument name in this ENTRY statement
255 !ERROR: 'z' appears more than once as a dummy argument name in this ENTRY statement