Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / module_equivalence_3.f90
blobd646f97407e59a39d2d0d01c918d2475cc6a1a45
1 ! { dg-do run }
2 ! This checks the fix for PR32103 in which not using one member
3 ! of an equivalence group would cause all memory of the equivalence
4 ! to be lost and subsequent incorrect referencing of the remaining
5 ! members.
7 ! Contributed by Toon Moene <toon@moene.indiv.nluug.nl>
9 module aap
10 real :: a(5) = (/1.0,2.0,3.0,4.0,5.0/)
11 real :: b(3)
12 real :: d(5) = (/1.0,2.0,3.0,4.0,5.0/)
13 equivalence (a(3),b(1))
14 end module aap
16 use aap, only : b
17 call foo
18 call bar
19 ! call foobar
20 contains
21 subroutine foo
22 use aap, only : c=>b
23 if (any(c .ne. b)) call abort ()
24 end subroutine
25 subroutine bar
26 use aap, only : a
27 if (any(a(3:5) .ne. b)) call abort ()
28 end subroutine
30 ! Make sure that bad things do not happen if we do not USE a or b.
32 subroutine foobar
33 use aap, only : d
34 if (any(d(3:5) .ne. b)) call abort ()
35 end subroutine
36 end
38 ! { dg-final { cleanup-modules "aap" } }