Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / resolve18.f90
blobedb59e9e131ebf23452909e833a6faafebb34ce1
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 module m1
3 implicit none
4 contains
5 subroutine foo(x)
6 real :: x
7 end subroutine
8 end module
10 !Note: PGI, Intel, GNU, and NAG allow this; Sun does not
11 module m2
12 use m1
13 implicit none
14 !WARNING: 'foo' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
15 interface foo
16 module procedure s
17 end interface
18 contains
19 subroutine s(i)
20 integer :: i
21 end subroutine
22 end module
24 subroutine foo
25 !ERROR: Cannot use-associate 'foo'; it is already declared in this scope
26 use m1
27 end
29 subroutine bar
30 !ERROR: Cannot use-associate 'bar'; it is already declared in this scope
31 use m1, bar => foo
32 end
34 !OK to use-associate a type with the same name as a generic
35 module m3a
36 type :: foo
37 end type
38 end
39 module m3b
40 use m3a
41 interface foo
42 end interface
43 end
45 ! Can't have derived type and function with same name
46 module m4a
47 type :: foo
48 end type
49 contains
50 !ERROR: 'foo' is already declared in this scoping unit
51 function foo(x)
52 end
53 end
54 ! Even if there is also a generic interface of that name
55 module m4b
56 type :: foo
57 end type
58 !ERROR: 'foo' is already declared in this scoping unit
59 interface foo
60 procedure :: foo
61 end interface foo
62 contains
63 function foo(x)
64 end
65 end
66 module m4c
67 type :: foo
68 end type
69 interface foo
70 !ERROR: 'foo' is already declared in this scoping unit
71 real function foo()
72 end function foo
73 end interface foo
74 end
76 ! Use associating a name that is a generic and a derived type
77 module m5a
78 interface g
79 end interface
80 type g
81 end type
82 end module
83 module m5b
84 use m5a
85 interface g
86 procedure f
87 end interface
88 type(g) :: x
89 contains
90 function f(i)
91 end function
92 end module
93 subroutine s5
94 use m5b
95 type(g) :: y
96 end
98 module m6
99 real :: f6
100 interface g6
101 !ERROR: 'f6' is already declared in this scoping unit
102 real function f6()
103 end function f6
104 end interface g6
105 end module m6
107 module m7
108 integer :: f7
109 interface g7
110 !ERROR: 'f7' is already declared in this scoping unit
111 real function f7()
112 end function f7
113 end interface g7
114 end module m7
116 module m8
117 real :: f8
118 interface g8
119 !ERROR: 'f8' is already declared in this scoping unit
120 subroutine f8()
121 end subroutine f8
122 end interface g8
123 end module m8
125 module m9
126 type f9
127 end type f9
128 !ERROR: 'f9' is already declared in this scoping unit
129 interface f9
130 real function f9()
131 end function f9
132 end interface f9
133 contains
134 function f9(x)
135 end function f9
136 end module m9
138 module m10
139 type :: t10
140 end type t10
141 interface f10
142 function f10()
143 end function f10
144 end interface f10
145 contains
146 !ERROR: 'f10' is already declared in this scoping unit
147 function f10(x)
148 end function f10
149 end module m10
151 module m11
152 type :: t11
153 end type t11
154 interface i11
155 function f11()
156 end function f11
157 end interface i11
158 contains
159 !ERROR: 'f11' is already declared in this scoping unit
160 function f11(x)
161 end function f11
162 end module m11
164 module m12
165 interface f12
166 function f12()
167 end function f12
168 end interface f12
169 contains
170 !ERROR: 'f12' is already declared in this scoping unit
171 function f12(x)
172 end function f12
173 end module m12
175 module m13
176 interface f13
177 function f13()
178 end function f13
179 end interface f13
180 contains
181 !ERROR: 'f13' is already declared in this scoping unit
182 function f13()
183 end function f13
184 end module m13
186 ! Not an error
187 module m14
188 interface gen1
189 module procedure s
190 end interface
191 generic :: gen2 => s
192 contains
193 subroutine s(x)
194 integer(1) :: x
195 end subroutine s
196 end module m14
197 module m15
198 use m14
199 interface gen1
200 module procedure gen1
201 end interface
202 generic :: gen2 => gen2
203 contains
204 subroutine gen1(x)
205 integer(2) :: x
206 end subroutine gen1
207 subroutine gen2(x)
208 integer(4) :: x
209 end subroutine gen2
210 end module m15