[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / modfile07.f90
blobc1100f04f80bb41fa2c30814a0398787749c1415
1 ! RUN: %S/test_modfile.sh %s %t %flang_fc1
2 ! REQUIRES: shell
3 ! Check modfile generation for generic interfaces
4 module m1
5 interface foo
6 real function s1(x,y)
7 real, intent(in) :: x
8 logical, intent(in) :: y
9 end function
10 complex function s2(x,y)
11 complex, intent(in) :: x
12 logical, intent(in) :: y
13 end function
14 end interface
15 generic :: operator ( + ) => s1, s2
16 interface operator ( /= )
17 logical function f1(x, y)
18 real, intent(in) :: x
19 logical, intent(in) :: y
20 end function
21 end interface
22 interface
23 logical function f2(x, y)
24 complex, intent(in) :: x
25 logical, intent(in) :: y
26 end function
27 logical function f3(x, y)
28 integer, intent(in) :: x
29 logical, intent(in) :: y
30 end function
31 end interface
32 generic :: operator(.ne.) => f2
33 generic :: operator(<>) => f3
34 private :: operator( .ne. )
35 interface bar
36 procedure :: s1
37 procedure :: s2
38 procedure :: s3
39 procedure :: s4
40 end interface
41 interface operator( .bar.)
42 procedure :: s1
43 procedure :: s2
44 procedure :: s3
45 procedure :: s4
46 end interface
47 contains
48 logical function s3(x,y)
49 logical, intent(in) :: x,y
50 end function
51 integer function s4(x,y)
52 integer, intent(in) :: x,y
53 end function
54 end
55 !Expect: m1.mod
56 !module m1
57 ! interface foo
58 ! procedure::s1
59 ! procedure::s2
60 ! end interface
61 ! interface
62 ! function s1(x,y)
63 ! real(4),intent(in)::x
64 ! logical(4),intent(in)::y
65 ! real(4)::s1
66 ! end
67 ! end interface
68 ! interface
69 ! function s2(x,y)
70 ! complex(4),intent(in)::x
71 ! logical(4),intent(in)::y
72 ! complex(4)::s2
73 ! end
74 ! end interface
75 ! interface operator(+)
76 ! procedure::s1
77 ! procedure::s2
78 ! end interface
79 ! interface operator(/=)
80 ! procedure::f1
81 ! procedure::f2
82 ! procedure::f3
83 ! end interface
84 ! private::operator(/=)
85 ! interface
86 ! function f1(x,y)
87 ! real(4),intent(in)::x
88 ! logical(4),intent(in)::y
89 ! logical(4)::f1
90 ! end
91 ! end interface
92 ! interface
93 ! function f2(x,y)
94 ! complex(4),intent(in)::x
95 ! logical(4),intent(in)::y
96 ! logical(4)::f2
97 ! end
98 ! end interface
99 ! interface
100 ! function f3(x,y)
101 ! integer(4),intent(in)::x
102 ! logical(4),intent(in)::y
103 ! logical(4)::f3
104 ! end
105 ! end interface
106 ! interface bar
107 ! procedure::s1
108 ! procedure::s2
109 ! procedure::s3
110 ! procedure::s4
111 ! end interface
112 ! interface operator(.bar.)
113 ! procedure::s1
114 ! procedure::s2
115 ! procedure::s3
116 ! procedure::s4
117 ! end interface
118 !contains
119 ! function s3(x,y)
120 ! logical(4),intent(in)::x
121 ! logical(4),intent(in)::y
122 ! logical(4)::s3
123 ! end
124 ! function s4(x,y)
125 ! integer(4),intent(in)::x
126 ! integer(4),intent(in)::y
127 ! integer(4)::s4
128 ! end
129 !end
131 module m1b
132 use m1
134 !Expect: m1b.mod
135 !module m1b
136 ! use m1,only:foo
137 ! use m1,only:s1
138 ! use m1,only:s2
139 ! use m1,only:operator(+)
140 ! use m1,only:f1
141 ! use m1,only:f2
142 ! use m1,only:f3
143 ! use m1,only:bar
144 ! use m1,only:operator(.bar.)
145 ! use m1,only:s3
146 ! use m1,only:s4
147 !end
149 module m1c
150 use m1, only: myfoo => foo
151 use m1, only: operator(.bar.)
152 use m1, only: operator(.mybar.) => operator(.bar.)
153 use m1, only: operator(+)
155 !Expect: m1c.mod
156 !module m1c
157 ! use m1,only:myfoo=>foo
158 ! use m1,only:operator(.bar.)
159 ! use m1,only:operator(.mybar.)=>operator(.bar.)
160 ! use m1,only:operator(+)
161 !end
163 module m2
164 interface foo
165 procedure foo
166 end interface
167 contains
168 complex function foo()
169 foo = 1.0
172 !Expect: m2.mod
173 !module m2
174 ! interface foo
175 ! procedure::foo
176 ! end interface
177 !contains
178 ! function foo()
179 ! complex(4)::foo
180 ! end
181 !end
183 module m2b
184 type :: foo
185 real :: x
186 end type
187 interface foo
188 end interface
189 private :: bar
190 interface bar
191 end interface
193 !Expect: m2b.mod
194 !module m2b
195 ! interface foo
196 ! end interface
197 ! type::foo
198 ! real(4)::x
199 ! end type
200 ! interface bar
201 ! end interface
202 ! private::bar
203 !end
205 ! Test interface nested inside another interface
206 module m3
207 interface g
208 subroutine s1(f)
209 interface
210 real function f(x)
211 interface
212 subroutine x()
213 end subroutine
214 end interface
215 end function
216 end interface
217 end subroutine
218 end interface
220 !Expect: m3.mod
221 !module m3
222 ! interface g
223 ! procedure::s1
224 ! end interface
225 ! interface
226 ! subroutine s1(f)
227 ! interface
228 ! function f(x)
229 ! interface
230 ! subroutine x()
231 ! end
232 ! end interface
233 ! real(4)::f
234 ! end
235 ! end interface
236 ! end
237 ! end interface
238 !end
240 module m4
241 interface foo
242 integer function foo()
243 end function
244 integer function f(x)
245 end function
246 end interface
248 subroutine s4
249 use m4
250 i = foo()
252 !Expect: m4.mod
253 !module m4
254 ! interface foo
255 ! procedure::foo
256 ! procedure::f
257 ! end interface
258 ! interface
259 ! function foo()
260 ! integer(4)::foo
261 ! end
262 ! end interface
263 ! interface
264 ! function f(x)
265 ! real(4)::x
266 ! integer(4)::f
267 ! end
268 ! end interface
269 !end
271 ! Compile contents of m4.mod and verify it gets the same thing again.
272 module m5
273 interface foo
274 procedure::foo
275 procedure::f
276 end interface
277 interface
278 function foo()
279 integer(4)::foo
281 end interface
282 interface
283 function f(x)
284 integer(4)::f
285 real(4)::x
287 end interface
289 !Expect: m5.mod
290 !module m5
291 ! interface foo
292 ! procedure::foo
293 ! procedure::f
294 ! end interface
295 ! interface
296 ! function foo()
297 ! integer(4)::foo
298 ! end
299 ! end interface
300 ! interface
301 ! function f(x)
302 ! real(4)::x
303 ! integer(4)::f
304 ! end
305 ! end interface
306 !end
308 module m6a
309 interface operator(<)
310 logical function lt(x, y)
311 logical, intent(in) :: x, y
312 end function
313 end interface
315 !Expect: m6a.mod
316 !module m6a
317 ! interface operator(<)
318 ! procedure::lt
319 ! end interface
320 ! interface
321 ! function lt(x,y)
322 ! logical(4),intent(in)::x
323 ! logical(4),intent(in)::y
324 ! logical(4)::lt
325 ! end
326 ! end interface
327 !end
329 module m6b
330 use m6a, only: operator(.lt.)
332 !Expect: m6b.mod
333 !module m6b
334 ! use m6a,only:operator(.lt.)
335 !end
337 module m7a
338 interface g_integer
339 module procedure s
340 end interface
341 private :: s
342 contains
343 subroutine s(x)
344 integer :: x
347 !Expect: m7a.mod
348 !module m7a
349 ! interface g_integer
350 ! procedure :: s
351 ! end interface
352 ! private :: s
353 !contains
354 ! subroutine s(x)
355 ! integer(4) :: x
356 ! end
357 !end
359 module m7b
360 interface g_real
361 module procedure s
362 end interface
363 private :: s
364 contains
365 subroutine s(x)
366 real :: x
367 end subroutine
369 !Expect: m7b.mod
370 !module m7b
371 ! interface g_real
372 ! procedure :: s
373 ! end interface
374 ! private :: s
375 !contains
376 ! subroutine s(x)
377 ! real(4) :: x
378 ! end
379 !end
381 module m7c
382 use m7a, only: g => g_integer
383 use m7b, only: g => g_real
384 interface g
385 module procedure s
386 end interface
387 private :: s
388 contains
389 subroutine s(x)
390 complex :: x
391 end subroutine
392 subroutine test()
393 real :: x
394 integer :: y
395 complex :: z
396 call g(x)
397 call g(y)
398 call g(z)
401 !Expect: m7c.mod
402 !module m7c
403 ! use m7b, only: g => g_real
404 ! use m7a, only: g => g_integer
405 ! interface g
406 ! procedure :: s
407 ! end interface
408 ! private :: s
409 !contains
410 ! subroutine s(x)
411 ! complex(4) :: x
412 ! end
413 ! subroutine test()
414 ! end
415 !end
417 ! Test m8 is like m7 but without renaming.
419 module m8a
420 interface g
421 module procedure s
422 end interface
423 private :: s
424 contains
425 subroutine s(x)
426 integer :: x
429 !Expect: m8a.mod
430 !module m8a
431 ! interface g
432 ! procedure :: s
433 ! end interface
434 ! private :: s
435 !contains
436 ! subroutine s(x)
437 ! integer(4) :: x
438 ! end
439 !end
441 module m8b
442 interface g
443 module procedure s
444 end interface
445 private :: s
446 contains
447 subroutine s(x)
448 real :: x
449 end subroutine
451 !Expect: m8b.mod
452 !module m8b
453 ! interface g
454 ! procedure :: s
455 ! end interface
456 ! private :: s
457 !contains
458 ! subroutine s(x)
459 ! real(4) :: x
460 ! end
461 !end
463 module m8c
464 use m8a
465 use m8b
466 interface g
467 module procedure s
468 end interface
469 private :: s
470 contains
471 subroutine s(x)
472 complex :: x
473 end subroutine
474 subroutine test()
475 real :: x
476 integer :: y
477 complex :: z
478 call g(x)
479 call g(y)
480 call g(z)
483 !Expect: m8c.mod
484 !module m8c
485 ! use m8b, only: g
486 ! use m8a, only: g
487 ! interface g
488 ! procedure :: s
489 ! end interface
490 ! private :: s
491 !contains
492 ! subroutine s(x)
493 ! complex(4) :: x
494 ! end
495 ! subroutine test()
496 ! end
497 !end
499 ! Merging a use-associated generic with a local generic
501 module m9a
502 interface g
503 module procedure s
504 end interface
505 private :: s
506 contains
507 subroutine s(x)
508 integer :: x
511 !Expect: m9a.mod
512 !module m9a
513 ! interface g
514 ! procedure :: s
515 ! end interface
516 ! private :: s
517 !contains
518 ! subroutine s(x)
519 ! integer(4) :: x
520 ! end
521 !end
523 module m9b
524 use m9a
525 interface g
526 module procedure s
527 end interface
528 private :: s
529 contains
530 subroutine s(x)
531 real :: x
533 subroutine test()
534 call g(1)
535 call g(1.0)
538 !Expect: m9b.mod
539 !module m9b
540 ! use m9a,only:g
541 ! interface g
542 ! procedure::s
543 ! end interface
544 ! private::s
545 !contains
546 ! subroutine s(x)
547 ! real(4)::x
548 ! end
549 ! subroutine test()
550 ! end
551 !end
553 ! Verify that equivalent names are used when generic operators are merged
555 module m10a
556 interface operator(.ne.)
557 end interface
559 !Expect: m10a.mod
560 !module m10a
561 ! interface operator(.ne.)
562 ! end interface
563 !end
565 module m10b
566 interface operator(<>)
567 end interface
569 !Expect: m10b.mod
570 !module m10b
571 ! interface operator(<>)
572 ! end interface
573 !end
575 module m10c
576 use m10a
577 use m10b
578 interface operator(/=)
579 end interface
581 !Expect: m10c.mod
582 !module m10c
583 ! use m10b,only:operator(.ne.)
584 ! use m10a,only:operator(.ne.)
585 ! interface operator(.ne.)
586 ! end interface
587 !end
589 module m10d
590 use m10a
591 use m10c
592 private :: operator(<>)
594 !Expect: m10d.mod
595 !module m10d
596 ! use m10c,only:operator(.ne.)
597 ! use m10a,only:operator(.ne.)
598 ! interface operator(.ne.)
599 ! end interface
600 ! private::operator(.ne.)
601 !end
603 module m11a
604 contains
605 subroutine s1()
608 !Expect: m11a.mod
609 !module m11a
610 !contains
611 ! subroutine s1()
612 ! end
613 !end
615 module m11b
616 use m11a
617 interface g
618 module procedure s1
619 end interface
621 !Expect: m11b.mod
622 !module m11b
623 ! use m11a,only:s1
624 ! interface g
625 ! procedure::s1
626 ! end interface
627 !end