coarray_41.f90: Add "-latomic" option if libatomic_available.
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr46804.f90
blobee44a56c89774db96674e626cb13e96add435ffb
1 ! PR rtl-optimization/46804
2 ! { dg-do run }
3 ! { dg-options "-O -fPIC -fexpensive-optimizations -fgcse -foptimize-register-move -fpeel-loops -fno-tree-loop-optimize" }
5 program main
6 integer, parameter :: n1 = 2, n2 = 3, n3 = 4, slen = 3
7 character (len = slen), dimension (n1, n2, n3) :: a
8 integer (kind = 1), dimension (2, 4) :: shift1
9 integer (kind = 2), dimension (2, 4) :: shift2
10 integer (kind = 4), dimension (2, 4) :: shift3
11 do i3 = 1, n3
12 do i2 = 1, n2
13 do i1 = 1, n1
14 a (i1, i2, i3) = 'ab'(i1:i1) // 'cde'(i2:i2) // 'fghi'(i3:i3)
15 end do
16 end do
17 end do
18 shift1 (1, :) = (/ 4, 11, 19, 20 /)
19 shift1 (2, :) = (/ 55, 5, 1, 2 /)
20 shift2 = shift1
21 shift3 = shift1
22 call test (cshift (a, shift2, 2))
23 call test (cshift (a, shift3, 2))
24 contains
25 subroutine test (b)
26 character (len = slen), dimension (n1, n2, n3) :: b
27 do i3 = 1, n3
28 do i2 = 1, n2
29 do i1 = 1, n1
30 i2p = mod (shift1 (i1, i3) + i2 - 1, n2) + 1
31 if (b (i1, i2, i3) .ne. a (i1, i2p, i3)) call abort
32 end do
33 end do
34 end do
35 end subroutine test
36 end program main