1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Tests valid and invalid ENTRY statements
5 !ERROR: ENTRY 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 may not appear in a separate module procedure
34 entry badentryinsmp
! 1571
39 !ERROR: ENTRY may appear only in a subroutine or function
40 entry badentryinprogram
! C1571
44 !ERROR: ENTRY 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: ENTRY dummy argument 'badarg2' is previously declared as an item that may not be used as a dummy argument
63 !ERROR: ENTRY dummy argument 'badarg4' is previously declared as an item that may not be used as a dummy argument
64 entry badargs(badarg1
,badarg2
,badarg3
,badarg4
,badarg5
)
74 double precision :: weird2
80 integer, allocatable
:: alloc
81 integer, pointer :: ptr
83 !ERROR: ENTRY name 'ibad1' may not be declared when RESULT() is present
84 entry ibad1() result(ibad1res
) ! C1570
85 !ERROR: 'ibad2' was previously declared as an item that may not be used as a function result
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
96 !These cases are all acceptably incompatible
97 entry iok3() result(weird1
)
98 entry iok4() result(weird2
)
99 entry iok5() result(weird3
)
100 entry iok6() result(weird4
)
101 !ERROR: Result of ENTRY is not compatible with result of containing function
102 entry ibadt1() result(weird5
)
103 !ERROR: Result of ENTRY is not compatible with result of containing function
104 entry ibadt2() result(weird6
)
105 !ERROR: Result of ENTRY is not compatible with result of containing function
106 entry ibadt3() result(iarr
)
107 !ERROR: Result of ENTRY is not compatible with result of containing function
108 entry ibadt4() result(alloc
)
109 !ERROR: Result of ENTRY is not compatible with result of containing function
110 entry ibadt5() result(ptr
)
112 !ERROR: 'isubr' was previously called as a subroutine
114 continue ! force transition to execution part
116 implicit = 666 ! ok, just ensure that it works
119 function chfunc() result(chr
)
120 character(len
=1) :: chr
121 character(len
=2) :: chr1
122 !ERROR: Result of ENTRY is not compatible with result of containing function
123 entry chfunc1() result(chr1
)
127 !ERROR: 'subr' is already defined as a global identifier
129 !ERROR: 'ifunc' is already defined as a global identifier
131 !ERROR: 'm1' is already defined as a global identifier
133 !ERROR: 'iok1' is already defined as a global identifier
137 !ERROR: 'iproc' was previously called as a function
142 !ERROR: EXTERNAL attribute not allowed on 'm2entry2'
147 entry m2entry2
! NOT ok
155 subroutine simplesubr
158 procedure(simplesubr
), pointer :: p
167 module subroutine m3entry1
172 !ERROR: 'm3entry1' is already declared in this scoping unit
179 module procedure m4entry1
182 module procedure m4entry2
185 module procedure m4entry3
189 entry m4entry1
! in implicit part
191 entry m4entry2
! in specification part
193 entry m4entry3
! in executable part
201 !ERROR: No explicit type declared for 'implicitbad1'
203 inone
= 0 ! force transition to execution part
204 !ERROR: No explicit type declared for 'implicitbad2'