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