[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / resolve17.f90
blob784abd4a52864f167d06f658b4b2fd7f3970f3e7
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 module m
3 integer :: foo
4 !Note: PGI, Intel, and GNU allow this; NAG and Sun do not
5 !ERROR: 'foo' is already declared in this scoping unit
6 interface foo
7 end interface
8 end module
10 module m2
11 interface s
12 end interface
13 contains
14 !WARNING: 's' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
15 subroutine s
16 end subroutine
17 end module
19 module m3
20 ! This is okay: s is generic and specific
21 interface s
22 procedure s2
23 end interface
24 interface s
25 procedure s
26 end interface
27 contains
28 subroutine s()
29 end subroutine
30 subroutine s2(x)
31 end subroutine
32 end module
34 module m4a
35 interface g
36 procedure s_real
37 end interface
38 contains
39 subroutine s_real(x)
40 end
41 end
42 module m4b
43 interface g
44 procedure s_int
45 end interface
46 contains
47 subroutine s_int(i)
48 end
49 end
50 ! Generic g should merge the two use-associated ones
51 subroutine s4
52 use m4a
53 use m4b
54 call g(123)
55 call g(1.2)
56 end
58 module m5a
59 interface g
60 procedure s_real
61 end interface
62 contains
63 subroutine s_real(x)
64 end
65 end
66 module m5b
67 interface gg
68 procedure s_int
69 end interface
70 contains
71 subroutine s_int(i)
72 end
73 end
74 ! Generic g should merge the two use-associated ones
75 subroutine s5
76 use m5a
77 use m5b, g => gg
78 call g(123)
79 call g(1.2)
80 end
82 module m6a
83 interface gg
84 procedure sa
85 end interface
86 contains
87 subroutine sa(x)
88 end
89 end
90 module m6b
91 interface gg
92 procedure sb
93 end interface
94 contains
95 subroutine sb(y)
96 end
97 end
98 subroutine s6
99 !ERROR: Generic 'g' may not have specific procedures 'sa' and 'sb' as their interfaces are not distinguishable
100 use m6a, g => gg
101 use m6b, g => gg
104 module m7a
105 interface g
106 procedure s1
107 end interface
108 contains
109 subroutine s1(x)
112 module m7b
113 interface g
114 procedure s2
115 end interface
116 contains
117 subroutine s2(x, y)
120 module m7c
121 interface g
122 procedure s3
123 end interface
124 contains
125 subroutine s3(x, y, z)
128 ! Merge the three use-associated generics
129 subroutine s7
130 use m7a
131 use m7b
132 use m7c
133 call g(1.0)
134 call g(1.0, 2.0)
135 call g(1.0, 2.0, 3.0)
138 module m8a
139 interface g
140 procedure s1
141 end interface
142 contains
143 subroutine s1(x)
146 module m8b
147 interface g
148 procedure s2
149 end interface
150 contains
151 subroutine s2(x, y)
154 module m8c
155 integer :: g
157 ! If merged generic conflicts with another USE, it is an error (if it is referenced)
158 subroutine s8
159 use m8a
160 use m8b
161 use m8c
162 !ERROR: Reference to 'g' is ambiguous
163 g = 1
166 module m9a
167 interface g
168 module procedure g
169 end interface
170 contains
171 subroutine g()
173 end module
174 module m9b
175 interface g
176 module procedure g
177 end interface
178 contains
179 subroutine g(x)
180 real :: x
182 end module
183 module m9c
184 interface g
185 module procedure g
186 end interface
187 contains
188 subroutine g()
190 end module
191 subroutine s9a
192 use m9a
193 !ERROR: Cannot use-associate generic interface 'g' with specific procedure of the same name when another such generic is in scope
194 use m9b
196 subroutine s9b
197 !ERROR: USE-associated generic 'g' may not have specific procedures 'g' and 'g' as their interfaces are not distinguishable
198 use m9a
199 !ERROR: Cannot use-associate generic interface 'g' with specific procedure of the same name when another such generic is in scope
200 use m9c
203 module m10a
204 interface g
205 module procedure s
206 end interface
207 private :: s
208 contains
209 subroutine s(x)
210 integer :: x
213 module m10b
214 use m10a
215 !ERROR: Generic 'g' may not have specific procedures 's' and 's' as their interfaces are not distinguishable
216 interface g
217 module procedure s
218 end interface
219 private :: s
220 contains
221 subroutine s(x)
222 integer :: x
226 module m11a
227 interface g
228 end interface
229 type g
230 end type
231 end module
232 module m11b
233 interface g
234 end interface
235 type g
236 end type
237 end module
238 module m11c
239 use m11a
240 !ERROR: Generic interface 'g' has ambiguous derived types from modules 'm11a' and 'm11b'
241 use m11b
242 end module
244 module m12a
245 interface ga
246 module procedure sa
247 end interface
248 contains
249 subroutine sa(i)
252 module m12b
253 use m12a
254 interface gb
255 module procedure sb
256 end interface
257 contains
258 subroutine sb(x)
261 module m12c
262 use m12b, only: gc => gb
264 module m12d
265 use m12a, only: g => ga
266 use m12c, only: g => gc
267 interface g
268 end interface
269 end module
271 module m13a
272 contains
273 subroutine subr
274 end subroutine
275 end module
276 module m13b
277 use m13a
278 interface subr
279 module procedure subr
280 end interface
281 end module
282 module m13c
283 use m13a
284 use m13b
285 contains
286 subroutine test
287 call subr
288 end subroutine
289 end module
290 module m13d
291 use m13b
292 use m13a
293 contains
294 subroutine test
295 call subr
296 end subroutine
297 end module
299 module m14a
300 type :: foo
301 integer :: n
302 end type
303 end module
304 module m14b
305 interface foo
306 module procedure bar
307 end interface
308 contains
309 real function bar(x)
310 real, intent(in) :: x
311 bar = x
312 end function
313 end module
314 module m14c
315 use m14a
316 use m14b
317 type(foo) :: x
318 end module
319 module m14d
320 use m14a
321 use m14b
322 type(foo) :: x
323 contains
324 subroutine test
325 real :: y
326 y = foo(1.0)
327 x = foo(2)
328 end subroutine
329 end module
330 module m14e
331 use m14b
332 use m14a
333 type(foo) :: x
334 contains
335 subroutine test
336 real :: y
337 y = foo(1.0)
338 x = foo(2)
339 end subroutine
340 end module
342 module m15a
343 interface foo
344 module procedure bar
345 end interface
346 contains
347 subroutine bar
348 end subroutine
349 end module
350 module m15b
351 !ERROR: Cannot use-associate 'foo'; it is already declared in this scope
352 use m15a
353 contains
354 subroutine foo
355 end subroutine
356 end module
357 module m15c
358 contains
359 subroutine foo
360 end subroutine
361 end module
362 module m15d
363 use m15a
364 use m15c
365 contains
366 subroutine test
367 !ERROR: Reference to 'foo' is ambiguous
368 call foo
369 end subroutine
370 end module