1! { dg-do run }
2! PR 15957
3! we used to return the wrong shape when the order parameter was used
4! in reshape.
5!
6INTEGER, 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/))
8
9integer :: k(2,3), m(2,4), n(2,3), o(2,4)
10
11k(1,:) = (/ 1, 3, 5 /)
12k(2,:) = (/ 2, 4, 6 /)
13
14m(1,:) = (/ 1, 2, 3, 4 /)
15m(2,:) = (/ 5, 6, 0, 0 /)
16
17! check that reshape does the right thing while constant folding
18if (any(i /= k)) call abort()
19if (any(j /= m)) call abort()
20
21! check that reshape does the right thing at runtime
22n = reshape ((/1,2,3,4,5,6/), (/2,3/))
23if (any(n /= k)) call abort()
24o = reshape ((/1,2,3,4,5,6/), (/2,4/), (/0,0/), (/2,1/))
25if (any(o /= m)) call abort()
26end
27
28