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