PR ipa/83051
[official-gcc.git] / gcc / testsuite / gfortran.dg / associate_15.f90
blob7e34eb518e0cc5d49578a74d22eead6bffda218f
1 ! { dg-do run }
2 ! Test the fix for PR58085, where the offset for 'x' was set to zero,
3 ! rather than -1.
5 ! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com>
7 module foo
8 contains
9 function bar (arg) result (res)
10 integer arg, res(3)
11 res = [arg, arg+1, arg +2]
12 end function
13 end module
14 use foo
15 real d(3,3)
16 integer a,b,c
17 character(48) line1, line2
18 associate (x=>shape(d))
19 a = x(1)
20 b = x(2)
21 write (line1, *) a, b
22 write (line2, *) x
23 if (trim (line1) .ne. trim (line2)) call abort
24 end associate
25 associate (x=>[1,2])
26 a = x(1)
27 b = x(2)
28 write (line1, *) a, b
29 write (line2, *) x
30 if (trim (line1) .ne. trim (line2)) call abort
31 end associate
32 associate (x=>bar(5)) ! make sure that we haven't broken function association
33 a = x(1)
34 b = x(2)
35 c = x(3)
36 write (line1, *) a, b, c
37 write (line2, *) x
38 if (trim (line1) .ne. trim (line2)) call abort
39 end associate
40 end