2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / subref_array_pointer_4.f90
blob19edfdca98af1a8059aa502121f8af7d3c70bcbf
1 ! { dg-do run }
2 ! Tests the fix for PR42309, in which the indexing of 'Q'
3 ! was off by one.
5 ! Contributed by Gilbert Scott <gilbert.scott@easynet.co.uk>
7 PROGRAM X
8 TYPE T
9 INTEGER :: I
10 REAL :: X
11 END TYPE T
12 TYPE(T), TARGET :: T1(0:3)
13 INTEGER, POINTER :: P(:)
14 REAL :: SOURCE(4) = [10., 20., 30., 40.]
16 T1%I = [1, 2, 3, 4]
17 T1%X = SOURCE
18 P => T1%I
19 CALL Z(P)
20 IF (ANY (T1%I .NE. [999, 2, 999, 4])) CALL ABORT
21 IF (ANY (T1%X .NE. SOURCE)) CALL ABORT
22 CONTAINS
23 SUBROUTINE Z(Q)
24 INTEGER, POINTER :: Q(:)
25 Q(1:3:2) = 999
26 END SUBROUTINE Z
27 END PROGRAM X