PR rtl-optimization/82913
[official-gcc.git] / gcc / testsuite / gfortran.fortran-torture / execute / dep_fails.f90
blobc8eec5c73ac712e5a5aa1bcc0fedc8f69c2d5fbf
1 ! This gives incorrect results when compiled with
2 ! the intel and pgf90 compilers
3 Program Strange
5 Implicit None
7 Type Link
8 Integer, Dimension(2) :: Next
9 End Type Link
11 Integer, Parameter :: N = 2
12 Integer, dimension (2, 4) :: results
13 Integer :: i, j
15 Type(Link), Dimension(:,:), Pointer :: Perm
16 Integer, Dimension(2) :: Current
18 Allocate (Perm(N,N))
20 ! Print*, 'Spanned by indices'
21 Do i = 1, N**2
22 Perm(mod(i-1,N)+1, (i-1)/N+1)%Next = (/ Mod(i,N) + 1, Mod(i/N+1,N)+1/)
23 ! Write(*,100) mod(i-1,N)+1, (i-1)/N+1, Perm(mod(i-1,N)+1, (i-1)/N+1)%Next
24 ! Expected output:
25 ! Spanned by indices
26 ! 1 1---> 2 2
27 ! 2 1---> 1 1
28 ! 1 2---> 2 1
29 ! 2 2---> 1 2
30 End Do
32 ! Print*, 'Spanned as a cycle'
33 Current = (/1,1/)
34 Do i = 1, n**2
35 results (:, i) = Perm(Current(1), Current(2))%Next
36 ! Write(*,100) Current, Perm(Current(1), Current(2))%Next
37 ! Expected output:
38 ! 1 1---> 2 2
39 ! 2 2---> 1 2
40 ! 1 2---> 2 1
41 ! 2 1---> 1 1
42 Current = Perm(Current(1), Current(2))%Next
43 End Do
45 if (any(results .ne. reshape ((/2,2,1,2,2,1,1,1/), (/2, 4/)))) call abort
47 ! 100 Format( 2I3, '--->', 2I3)
48 DeAllocate (Perm)
50 End Program Strange