if (!type_check (order, 3, BT_INTEGER))
return false;
- if (order->expr_type == EXPR_ARRAY)
+ if (order->expr_type == EXPR_ARRAY && gfc_is_constant_expr (order))
{
int i, order_size, dim, perm[GFC_MAX_DIMENSIONS];
gfc_expr *e;
--- /dev/null
+! { dg-do run }
+program p
+ character(len=20) s1, s2
+ integer, allocatable :: n(:)
+ n = [2,1]
+ s1 = '1 5 2 6 3 0 4 0'
+ write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [2,1])
+ if (trim(s1) /= trim(s2)) call abort
+ write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], n)
+ if (trim(s1) /= trim(s2)) call abort
+ write(s2,'(8(I0,1x))') reshape ([1,2,3,4,5,6], [2,4], [0,0], [n])
+ if (trim(s1) /= trim(s2)) call abort
+end