PR rtl-optimization/82913
[official-gcc.git] / gcc / testsuite / gfortran.fortran-torture / execute / where20.f90
blobb0456500d13f9d3f905c0088003db1a030eb187f
1 ! Test the dependency checking in simple where. This
2 ! did not work and was fixed as part of the patch for
3 ! pr24519.
5 program where_20
6 integer :: a(4)
7 integer :: b(3)
8 integer :: c(3)
9 integer :: d(3) = (/1, 2, 3/)
10 equivalence (a(1), b(1)), (a(2), c(1))
12 ! This classic case worked before the patch.
13 a = (/1, 2, 3, 4/)
14 where (b .gt. 1) a(2:4) = a(1:3)
15 if (any(a .ne. (/1,2,2,3/))) call abort ()
17 ! This is the original manifestation of the problem
18 ! and is repeated in where_19.f90.
19 a = (/1, 2, 3, 4/)
20 where (b .gt. 1)
21 c = b
22 endwhere
23 if (any(a .ne. (/1,2,2,3/))) call abort ()
25 ! Mask to.destination dependency.
26 a = (/1, 2, 3, 4/)
27 where (b .gt. 1)
28 c = d
29 endwhere
30 if (any(a .ne. (/1,2,2,3/))) call abort ()
32 ! Source to.destination dependency.
33 a = (/1, 2, 3, 4/)
34 where (d .gt. 1)
35 c = b
36 endwhere
37 if (any(a .ne. (/1,2,2,3/))) call abort ()
39 ! Check the simple where.
40 a = (/1, 2, 3, 4/)
41 where (b .gt. 1) c = b
42 if (any(a .ne. (/1,2,2,3/))) call abort ()
44 ! This was OK before the patch.
45 a = (/1, 2, 3, 4/)
46 where (b .gt. 1)
47 where (d .gt. 1)
48 c = b
49 end where
50 endwhere
51 if (any(a .ne. (/1,2,2,3/))) call abort ()
53 end program