103 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Test USE statements that use same module multiple times mixed with rename3! clauses and ONLY clauses4module m15 integer :: a = 16 integer :: b = 27end module m18module m29 integer :: a = 310end module m211module m312 integer :: a = 113 type t114 real t1_value15 end type16 type t217 complex t2_value18 end type19end module m320module m421 use m122end module m423module m524 use m125 use m1, z=>a26end module m527module m628 use m1, only : a29end module m630program testUse131 use m132 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 associated34 !ERROR: 'a' is use-associated from module 'm2' and cannot be re-declared35 integer :: a = 236end37subroutine testUse238 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 association40 !ERROR: 'a' is use-associated from module 'm1' and cannot be re-declared41 integer :: a = 242end43subroutine testUse344 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 association46 integer :: a = 247end48subroutine testUse449 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-declared52 integer :: b = 253end54subroutine testUse555 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 rename57 integer :: a = 258end59subroutine testUse660 use m1, z => a ! Hides m1's "a"61 use m1, y => b ! Hides m1's "b"62 integer :: a = 4 ! OK63 integer :: b = 5 ! OK64end65subroutine testUse766 use m3,t1=>t2,t2=>t1 ! Looks weird but all is good67 type(t1) x68 type(t2) y69 x%t2_value = a70 y%t1_value = z71end72subroutine testUse873 use m4 ! This USE associates all of m174 !ERROR: 'a' is use-associated from module 'm4' and cannot be re-declared75 integer :: a = 276end77subroutine testUse978 use m579 integer :: a = 280end81subroutine testUse1082 use m483 use m4, z=>a ! This rename erases the USE assocated "a" from m184 integer :: a = 285end86subroutine testUse1187 use m688 use m6, z=>a ! This rename erases the USE assocated "a" from m189 integer :: a = 290end91subroutine testUse1292 use m4 ! This USE associates "a" from m193 use m1, z=>a ! This renames the "a" from m1, but not the one through m494 !ERROR: 'a' is use-associated from module 'm4' and cannot be re-declared95 integer :: a = 296end97subroutine testUse1398 use m1, a => a99 use m1, z => a ! should not erase 'a', it was renamed100 !ERROR: 'a' is use-associated from module 'm1' and cannot be re-declared101 integer :: a = 13102end103