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