1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! When a module subprogram has the MODULE prefix the following must match
4 ! with the corresponding separate module procedure interface body:
5 ! - C1549: characteristics and dummy argument names
6 ! - C1550: binding label
7 ! - C1551: NON_RECURSIVE prefix
11 module subroutine s4(x
)
14 module subroutine s5(x
, y
)
18 module subroutine s6(x
, y
)
22 module subroutine s7(x
, y
, z
)
27 module subroutine s8(x
, y
, z
)
32 module subroutine s9(x
, y
, z
, w
)
43 module subroutine s4(x
)
44 !ERROR: The intent of dummy argument 'x' does not match the intent of the corresponding argument in the interface body
45 real, intent(out
) :: x
47 module subroutine s5(x
, y
)
48 !ERROR: Dummy argument 'x' has the OPTIONAL attribute; the corresponding argument in the interface body does not
49 real, pointer, optional
:: x
50 !ERROR: Dummy argument 'y' does not have the VALUE attribute; the corresponding argument in the interface body does
53 module subroutine s6(x
, y
)
54 !ERROR: Dummy argument 'x' has type INTEGER(4); the corresponding argument in the interface body has type REAL(4)
56 !ERROR: Dummy argument 'y' has type REAL(8); the corresponding argument in the interface body has type REAL(4)
59 module subroutine s7(x
, y
, z
)
60 integer, parameter :: n
= 8
63 !ERROR: The shape of dummy argument 'z' does not match the shape of the corresponding argument in the interface body
66 module subroutine s8(x
, y
, z
)
67 !ERROR: The shape of dummy argument 'x' does not match the shape of the corresponding argument in the interface body
70 !ERROR: The shape of dummy argument 'z' does not match the shape of the corresponding argument in the interface body
73 module subroutine s9(x
, y
, z
, w
)
75 !ERROR: Dummy argument 'y' has type CHARACTER(KIND=1,LEN=5_8); the corresponding argument in the interface body has type CHARACTER(KIND=1,LEN=4_8)
78 !ERROR: Dummy argument 'w' has type CHARACTER(KIND=1,LEN=4_8); the corresponding argument in the interface body has type CHARACTER(KIND=1,LEN=*)
85 module subroutine s1(x
, y
)
87 real, intent(out
) :: y
89 module subroutine s2(x
, y
)
91 real, intent(out
) :: y
93 module subroutine s3(x
, y
)
97 module subroutine s4()
99 non_recursive
module subroutine s5()
106 !ERROR: Module subprogram 's1' has 3 args but the corresponding interface body has 2
107 module subroutine s1(x
, y
, z
)
108 real, intent(in
) :: x
109 real, intent(out
) :: y
112 module subroutine s2(x
, z
)
113 real, intent(in
) :: x
114 !ERROR: Dummy argument name 'z' does not match corresponding name 'y' in interface body
115 real, intent(out
) :: z
117 module subroutine s3(x
, y
)
118 !ERROR: Dummy argument 'x' is a procedure; the corresponding argument in the interface body is not
120 !ERROR: Dummy argument 'y' is a data object; the corresponding argument in the interface body is not
123 !ERROR: Module subprogram 's4' has NON_RECURSIVE prefix but the corresponding interface body does not
124 non_recursive
module subroutine s4()
126 !ERROR: Module subprogram 's5' does not have NON_RECURSIVE prefix but the corresponding interface body does
127 module subroutine s5()
133 module subroutine s1()
135 module subroutine s2() bind(c
, name
="s2")
137 module subroutine s3() bind(c
, name
="s3")
139 module subroutine s4() bind(c
, name
=" s4")
141 module subroutine s5() bind(c
)
143 module subroutine s6() bind(c
)
149 character(*), parameter :: suffix
= "_xxx"
151 !ERROR: Module subprogram 's1' has a binding label but the corresponding interface body does not
152 !ERROR: Module subprogram 's1' and its corresponding interface body are not both BIND(C)
153 module subroutine s1() bind(c
, name
="s1")
155 !ERROR: Module subprogram 's2' does not have a binding label but the corresponding interface body does
156 !ERROR: Module subprogram 's2' and its corresponding interface body are not both BIND(C)
157 module subroutine s2()
159 !ERROR: Module subprogram 's3' has binding label 's3_xxx' but the corresponding interface body has 's3'
160 module subroutine s3() bind(c
, name
="s3" // suffix
)
162 module subroutine s4() bind(c
, name
="s4 ")
164 module subroutine s5() bind(c
, name
=" s5")
166 !ERROR: Module subprogram 's6' has binding label 'not_s6' but the corresponding interface body has 's6'
167 module subroutine s6() bind(c
, name
="not_s6")
174 module subroutine s1(x
, y
, z
)
175 procedure(real), pointer, intent(in
) :: x
176 procedure(real), pointer, intent(out
) :: y
177 procedure(real), pointer, intent(out
) :: z
179 module subroutine s2(x
, y
)
180 procedure(real), pointer :: x
188 module subroutine s1(x
, y
, z
)
189 procedure(real), pointer, intent(in
) :: x
190 !ERROR: The intent of dummy argument 'y' does not match the intent of the corresponding argument in the interface body
191 procedure(real), pointer, intent(inout
) :: y
192 !ERROR: The intent of dummy argument 'z' does not match the intent of the corresponding argument in the interface body
193 procedure(real), pointer :: z
195 module subroutine s2(x
, y
)
196 !ERROR: Dummy argument 'x' has the OPTIONAL attribute; the corresponding argument in the interface body does not
197 !ERROR: Dummy argument 'x' does not have the POINTER attribute; the corresponding argument in the interface body does
198 procedure(real), optional
:: x
199 !ERROR: Dummy argument 'y' has the POINTER attribute; the corresponding argument in the interface body does not
200 procedure(real), pointer :: y
209 subroutine s_real2(x
)
212 subroutine s_integer(x
)
215 module subroutine s1(x
)
216 procedure(s_real
) :: x
218 module subroutine s2(x
)
219 procedure(s_real
) :: x
226 module subroutine s1(x
)
228 procedure(s_real2
) :: x
230 module subroutine s2(x
)
231 !ERROR: Dummy procedure 'x' does not match the corresponding argument in the interface body
232 procedure(s_integer
) :: x
241 module subroutine s2()
248 !ERROR: Module subroutine 'f1' was declared as a function in the corresponding interface body
249 module subroutine f1()
251 !ERROR: Module function 's2' was declared as a subroutine in the corresponding interface body
273 real module function f1()
275 !ERROR: Return type of function 'f2' does not match return type of the corresponding interface body
276 integer module function f2()
278 !ERROR: Return type of function 'f3' does not match return type of the corresponding interface body
287 module subroutine s1(x
, *)
295 !ERROR: Dummy argument 1 of 's1' is an alternate return indicator but the corresponding argument in the interface body is not
296 !ERROR: Dummy argument 2 of 's1' is not an alternate return indicator but the corresponding argument in the interface body is
297 module subroutine s1(*, x
)
304 pure elemental
module subroutine s1
311 !Ensure no spurious error about mismatching attributes
318 module subroutine sub1(s
)
321 module subroutine sub2(s
)
329 module subroutine sub1(s
)
330 character(len
=-1) s
! ok
332 module subroutine sub2(s
)
333 !ERROR: Dummy argument 's' has type CHARACTER(KIND=1,LEN=1_8); the corresponding argument in the interface body has type CHARACTER(KIND=1,LEN=0_8)