AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins (#118297)
[llvm-project.git] / flang / test / Semantics / modfile41.f90
blobe1335a8f1de41a5f3fc69010e565f709f5a2ebe2
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test USE statements that use same module multiple times mixed with rename
3 ! clauses and ONLY clauses
4 module m1
5 integer :: a = 1
6 integer :: b = 2
7 end module m1
8 module m2
9 integer :: a = 3
10 end module m2
11 module m3
12 integer :: a = 1
13 type t1
14 real t1_value
15 end type
16 type t2
17 complex t2_value
18 end type
19 end module m3
20 module m4
21 use m1
22 end module m4
23 module m5
24 use m1
25 use m1, z=>a
26 end module m5
27 module m6
28 use m1, only : a
29 end module m6
30 program testUse1
31 use m1
32 use m1,z=>a ! This prevents the use association of m1's "a" as local "a"
33 use m2 ! m2's version of "a" gets use associated
34 !ERROR: 'a' is use-associated from module 'm2' and cannot be re-declared
35 integer :: a = 2
36 end
37 subroutine testUse2
38 use m1,only : a ! This forces the use association of m1's "a" as local "a"
39 use m1,z=>a ! This rename doesn't affect the previous forced USE association
40 !ERROR: 'a' is use-associated from module 'm1' and cannot be re-declared
41 integer :: a = 2
42 end
43 subroutine testUse3
44 use m1 ! By itself, this would use associate m1's "a" with a local "a"
45 use m1,z=>a ! This rename of m1'a "a" removes the previous use association
46 integer :: a = 2
47 end
48 subroutine testUse4
49 use m1,only : a ! Use associate m1's "a" with local "a"
50 use m1,z=>a ! Also use associate m1's "a" with local "z", also pulls in "b"
51 !ERROR: 'b' is use-associated from module 'm1' and cannot be re-declared
52 integer :: b = 2
53 end
54 subroutine testUse5
55 use m1,z=>a ! The rename prevents creation of a local "a"
56 use m1 ! Does not create a local "a" because of the previous rename
57 integer :: a = 2
58 end
59 subroutine testUse6
60 use m1, z => a ! Hides m1's "a"
61 use m1, y => b ! Hides m1's "b"
62 integer :: a = 4 ! OK
63 integer :: b = 5 ! OK
64 end
65 subroutine testUse7
66 use m3,t1=>t2,t2=>t1 ! Looks weird but all is good
67 type(t1) x
68 type(t2) y
69 x%t2_value = a
70 y%t1_value = z
71 end
72 subroutine testUse8
73 use m4 ! This USE associates all of m1
74 !ERROR: 'a' is use-associated from module 'm4' and cannot be re-declared
75 integer :: a = 2
76 end
77 subroutine testUse9
78 use m5
79 integer :: a = 2
80 end
81 subroutine testUse10
82 use m4
83 use m4, z=>a ! This rename erases the USE assocated "a" from m1
84 integer :: a = 2
85 end
86 subroutine testUse11
87 use m6
88 use m6, z=>a ! This rename erases the USE assocated "a" from m1
89 integer :: a = 2
90 end
91 subroutine testUse12
92 use m4 ! This USE associates "a" from m1
93 use m1, z=>a ! This renames the "a" from m1, but not the one through m4
94 !ERROR: 'a' is use-associated from module 'm4' and cannot be re-declared
95 integer :: a = 2
96 end
97 subroutine testUse13
98 use m1, a => a
99 use m1, z => a ! should not erase 'a', it was renamed
100 !ERROR: 'a' is use-associated from module 'm1' and cannot be re-declared
101 integer :: a = 13