2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr15957.f90
blobb1439131f894a39e561422b302192333205fd3d1
1 ! { dg-do run }
2 ! PR 15957
3 ! we used to return the wrong shape when the order parameter was used
4 ! in reshape.
6 INTEGER, parameter :: i(2,3) = reshape ((/1,2,3,4,5,6/), (/2,3/)), &
7 j(2,4) = reshape ((/1,2,3,4,5,6/), (/2,4/), (/0,0/), (/2,1/))
9 integer :: k(2,3), m(2,4), n(2,3), o(2,4)
11 k(1,:) = (/ 1, 3, 5 /)
12 k(2,:) = (/ 2, 4, 6 /)
14 m(1,:) = (/ 1, 2, 3, 4 /)
15 m(2,:) = (/ 5, 6, 0, 0 /)
17 ! check that reshape does the right thing while constant folding
18 if (any(i /= k)) call abort()
19 if (any(j /= m)) call abort()
21 ! check that reshape does the right thing at runtime
22 n = reshape ((/1,2,3,4,5,6/), (/2,3/))
23 if (any(n /= k)) call abort()
24 o = reshape ((/1,2,3,4,5,6/), (/2,4/), (/0,0/), (/2,1/))
25 if (any(o /= m)) call abort()
26 end