1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
4 ! When a module subprogram has the MODULE prefix the following must match
5 ! with the corresponding separate module procedure interface body:
6 ! - C1549: characteristics and dummy argument names
7 ! - C1550: binding label
8 ! - C1551: NON_RECURSIVE prefix
12 module subroutine s4(x
)
15 module subroutine s5(x
, y
)
19 module subroutine s6(x
, y
)
23 module subroutine s7(x
, y
, z
)
28 module subroutine s8(x
, y
, z
)
33 module subroutine s9(x
, y
, z
, w
)
44 module subroutine s4(x
)
45 !ERROR: The intent of dummy argument 'x' does not match the intent of the corresponding argument in the interface body
46 real, intent(out
) :: x
48 module subroutine s5(x
, y
)
49 !ERROR: Dummy argument 'x' has the OPTIONAL attribute; the corresponding argument in the interface body does not
50 real, pointer, optional
:: x
51 !ERROR: Dummy argument 'y' does not have the VALUE attribute; the corresponding argument in the interface body does
54 module subroutine s6(x
, y
)
55 !ERROR: Dummy argument 'x' has type INTEGER(4); the corresponding argument in the interface body has type REAL(4)
57 !ERROR: Dummy argument 'y' has type REAL(8); the corresponding argument in the interface body has type REAL(4)
60 module subroutine s7(x
, y
, z
)
61 integer, parameter :: n
= 8
64 !ERROR: The shape of dummy argument 'z' does not match the shape of the corresponding argument in the interface body
67 module subroutine s8(x
, y
, z
)
68 !ERROR: The shape of dummy argument 'x' does not match the shape of the corresponding argument in the interface body
71 !ERROR: The shape of dummy argument 'z' does not match the shape of the corresponding argument in the interface body
74 module subroutine s9(x
, y
, z
, w
)
76 !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)
79 !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=*)
86 module subroutine s1(x
, y
)
88 real, intent(out
) :: y
90 module subroutine s2(x
, y
)
92 real, intent(out
) :: y
94 module subroutine s3(x
, y
)
98 module subroutine s4()
100 non_recursive
module subroutine s5()
107 !ERROR: Module subprogram 's1' has 3 args but the corresponding interface body has 2
108 module subroutine s1(x
, y
, z
)
109 real, intent(in
) :: x
110 real, intent(out
) :: y
113 module subroutine s2(x
, z
)
114 real, intent(in
) :: x
115 !ERROR: Dummy argument name 'z' does not match corresponding name 'y' in interface body
116 real, intent(out
) :: z
118 module subroutine s3(x
, y
)
119 !ERROR: Dummy argument 'x' is a procedure; the corresponding argument in the interface body is not
121 !ERROR: Dummy argument 'y' is a data object; the corresponding argument in the interface body is not
124 !ERROR: Module subprogram 's4' has NON_RECURSIVE prefix but the corresponding interface body does not
125 non_recursive
module subroutine s4()
127 !ERROR: Module subprogram 's5' does not have NON_RECURSIVE prefix but the corresponding interface body does
128 module subroutine s5()
134 module subroutine s1()
136 module subroutine s2() bind(c
, name
="s2")
138 module subroutine s3() bind(c
, name
="s3")
140 module subroutine s4() bind(c
, name
=" s4")
142 module subroutine s5() bind(c
)
144 module subroutine s6() bind(c
)
150 character(*), parameter :: suffix
= "_xxx"
152 !ERROR: Module subprogram 's1' has a binding label but the corresponding interface body does not
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 module subroutine s2()
158 !ERROR: Module subprogram 's3' has binding label 's3_xxx' but the corresponding interface body has 's3'
159 module subroutine s3() bind(c
, name
="s3" // suffix
)
161 module subroutine s4() bind(c
, name
="s4 ")
163 module subroutine s5() bind(c
, name
=" s5")
165 !ERROR: Module subprogram 's6' has binding label 'not_s6' but the corresponding interface body has 's6'
166 module subroutine s6() bind(c
, name
="not_s6")
173 module subroutine s1(x
, y
, z
)
174 procedure(real), pointer, intent(in
) :: x
175 procedure(real), pointer, intent(out
) :: y
176 procedure(real), pointer, intent(out
) :: z
178 module subroutine s2(x
, y
)
179 procedure(real), pointer :: x
187 module subroutine s1(x
, y
, z
)
188 procedure(real), pointer, intent(in
) :: x
189 !ERROR: The intent of dummy argument 'y' does not match the intent of the corresponding argument in the interface body
190 procedure(real), pointer, intent(inout
) :: y
191 !ERROR: The intent of dummy argument 'z' does not match the intent of the corresponding argument in the interface body
192 procedure(real), pointer :: z
194 module subroutine s2(x
, y
)
195 !ERROR: Dummy argument 'x' has the OPTIONAL attribute; the corresponding argument in the interface body does not
196 !ERROR: Dummy argument 'x' does not have the POINTER attribute; the corresponding argument in the interface body does
197 procedure(real), optional
:: x
198 !ERROR: Dummy argument 'y' has the POINTER attribute; the corresponding argument in the interface body does not
199 procedure(real), pointer :: y
208 subroutine s_real2(x
)
211 subroutine s_integer(x
)
214 module subroutine s1(x
)
215 procedure(s_real
) :: x
217 module subroutine s2(x
)
218 procedure(s_real
) :: x
225 module subroutine s1(x
)
227 procedure(s_real2
) :: x
229 module subroutine s2(x
)
230 !ERROR: Dummy procedure 'x' does not match the corresponding argument in the interface body
231 procedure(s_integer
) :: x
240 module subroutine s2()
247 !ERROR: Module subroutine 'f1' was declared as a function in the corresponding interface body
248 module subroutine f1()
250 !ERROR: Module function 's2' was declared as a subroutine in the corresponding interface body
272 real module function f1()
274 !ERROR: Return type of function 'f2' does not match return type of the corresponding interface body
275 integer module function f2()
277 !ERROR: Return type of function 'f3' does not match return type of the corresponding interface body
286 module subroutine s1(x
, *)
294 !ERROR: Dummy argument 1 of 's1' is an alternate return indicator but the corresponding argument in the interface body is not
295 !ERROR: Dummy argument 2 of 's1' is not an alternate return indicator but the corresponding argument in the interface body is
296 module subroutine s1(*, x
)