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.
6!
7! Contributed by Toon Moene <toon@moene.indiv.nluug.nl>
8!
9module 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))
14end module aap
15
16  use aap, only : b
17  call foo
18  call bar
19!  call foobar
20contains
21  subroutine foo
22    use aap, only : c=>b
23    if (any(c .ne. b)) STOP 1
24  end subroutine
25  subroutine bar
26    use aap, only : a
27    if (any(a(3:5) .ne. b)) STOP 2
28  end subroutine
29
30! Make sure that bad things do not happen if we do not USE a or b.
31
32  subroutine foobar
33    use aap, only : d
34    if (any(d(3:5) .ne. b)) STOP 3
35  end subroutine
36end
37