annotate gcc/testsuite/gfortran.dg/allocate_with_source_12.f03 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do run }
kono
parents:
diff changeset
2 !
kono
parents:
diff changeset
3 ! Checks the fix for PR67171, where the second ALLOCATE with and array section
kono
parents:
diff changeset
4 ! SOURCE produced a zero index based temporary, which threw the assignment.
kono
parents:
diff changeset
5 !
kono
parents:
diff changeset
6 ! Contributed by Anton Shterenlikht <mexas@bristol.ac.uk>
kono
parents:
diff changeset
7 !
kono
parents:
diff changeset
8 program z
kono
parents:
diff changeset
9 implicit none
kono
parents:
diff changeset
10 integer, parameter :: DIM1_SIZE = 10
kono
parents:
diff changeset
11 real, allocatable :: d(:,:), tmp(:,:)
kono
parents:
diff changeset
12 integer :: i, errstat
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 allocate (d(DIM1_SIZE, 2), source = 0.0, stat=errstat )
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 d(:,1) = [( real (i), i=1,DIM1_SIZE)]
kono
parents:
diff changeset
17 d(:,2) = [( real(2*i), i=1,DIM1_SIZE)]
kono
parents:
diff changeset
18 ! write (*,*) d(1, :)
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 call move_alloc (from = d, to = tmp)
kono
parents:
diff changeset
21 ! write (*,*) tmp( 1, :)
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 allocate (d(DIM1_SIZE / 2, 2), source = tmp(1 : DIM1_SIZE / 2, :) , stat=errstat)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
24 if (any (d .ne. tmp(1:DIM1_SIZE/2,:))) STOP 1
111
kono
parents:
diff changeset
25 deallocate (d)
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 allocate (d(DIM1_SIZE / 2, 2), source = foo (tmp(1 : DIM1_SIZE / 2, :)) , stat=errstat)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
28 if (any (d .ne. tmp(1 : DIM1_SIZE / 2, :))) STOP 2
111
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 deallocate (tmp , d)
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 contains
kono
parents:
diff changeset
33 function foo (arg) result (res)
kono
parents:
diff changeset
34 real :: arg(:,:)
kono
parents:
diff changeset
35 real :: res(size (arg, 1), size (arg, 2))
kono
parents:
diff changeset
36 res = arg
kono
parents:
diff changeset
37 end function
kono
parents:
diff changeset
38 end program z