2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / dependency_3.f90
bloba9dfe935ea4af5daf7377fcd8f2c102d172ba75e
1 ! { dg-do run }
2 ! Tests the fix for PR24519, in which assignments with the same
3 ! range of an assumed shape array, on the lhs and rhs, would be
4 ! treated as causing a dependency.
6 ! Contributed by Paul.Thomas <pault@gcc.gnu.org>
8 integer, parameter :: n = 100
9 real :: x(n, n), v
10 x = 1
11 v = 0.1
12 call foo (x, v)
13 if (abs(sum (x) - 91.10847) > 1e-3) print *, sum (x)
14 contains
15 subroutine foo (b, d)
16 real :: b(:, :)
17 real :: temp(n), c, d
18 integer :: j, k
19 do k = 1, n
20 temp = b(:,k)
21 do j = 1, n
22 c = b(k,j)*d
23 b(:,j) = b(:,j)-temp*c ! This was the offending assignment.
24 b(k,j) = c
25 end do
26 end do
27 end subroutine foo
28 end