111
|
1 ! { dg-do run }
|
|
2 ! { dg-options "-ftest-forall-temp" }
|
|
3 ! This is a copy of aliasing_dummy_4.f90, with an option set to improve
|
|
4 ! test coverage by forcing forall code to use a temporary.
|
|
5 !
|
|
6 program test_f90
|
|
7
|
|
8 integer, parameter :: N = 2
|
|
9
|
|
10 type test_type
|
|
11 integer a(N, N)
|
|
12 end type
|
|
13
|
|
14 type (test_type) s(N, N)
|
|
15
|
|
16 forall (l = 1:N, m = 1:N) &
|
|
17 s(l, m)%a(:, :) = reshape ([((i*l + 10*j*m +100, i = 1, N), j = 1, N)], [N, N])
|
|
18
|
|
19 call test_sub(s%a(1, 1), 1000) ! Test the original problem.
|
|
20
|
131
|
21 if ( any (s(1, 1)%a(:, :) /= reshape ([1111, 112, 121, 122], [2, 2]))) STOP 1
|
|
22 if ( any (s(1, 2)%a(:, :) /= reshape ([1121, 122, 141, 142], [2, 2]))) STOP 2
|
|
23 if ( any (s(2, 1)%a(:, :) /= reshape ([1112, 114, 122, 124], [2, 2]))) STOP 3
|
|
24 if ( any (s(2, 2)%a(:, :) /= reshape ([1122, 124, 142, 144], [2, 2]))) STOP 4
|
111
|
25
|
|
26 call test_sub(s(1, 1)%a(:, :), 1000) ! Check "normal" references.
|
|
27
|
131
|
28 if ( any (s(1, 1)%a(:, :) /= reshape ([2111,1112,1121,1122], [2, 2]))) STOP 5
|
|
29 if ( any (s(1, 2)%a(:, :) /= reshape ([1121, 122, 141, 142], [2, 2]))) STOP 6
|
|
30 if ( any (s(2, 1)%a(:, :) /= reshape ([1112, 114, 122, 124], [2, 2]))) STOP 7
|
|
31 if ( any (s(2, 2)%a(:, :) /= reshape ([1122, 124, 142, 144], [2, 2]))) STOP 8
|
111
|
32 contains
|
|
33 subroutine test_sub(array, offset)
|
|
34 integer array(:, :), offset
|
|
35
|
|
36 forall (i = 1:N, j = 1:N) &
|
|
37 array(i, j) = array(i, j) + offset
|
|
38 end subroutine
|
|
39 end program
|
|
40
|