+2019-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/91565
+ * simplify.c (gfc_simplify_reshape): Add additional checks of the
+ ORDER dummy argument.
+
2019-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91564
mpz_init (index);
rank = 0;
+ for (i = 0; i < GFC_MAX_DIMENSIONS; i++)
+ x[i] = 0;
+
for (;;)
{
e = gfc_constructor_lookup_expr (shape_exp->value.constructor, rank);
}
else
{
- for (i = 0; i < rank; i++)
- x[i] = 0;
+ mpz_t size;
+ int order_size, shape_size;
+
+ if (order_exp->rank != shape_exp->rank)
+ {
+ gfc_error ("Shapes of ORDER at %L and SHAPE at %L are different",
+ &order_exp->where, &shape_exp->where);
+ return &gfc_bad_expr;
+ }
+
+ gfc_array_size (shape_exp, &size);
+ shape_size = mpz_get_ui (size);
+ mpz_clear (size);
+ gfc_array_size (order_exp, &size);
+ order_size = mpz_get_ui (size);
+ mpz_clear (size);
+ if (order_size != shape_size)
+ {
+ gfc_error ("Sizes of ORDER at %L and SHAPE at %L are different",
+ &order_exp->where, &shape_exp->where);
+ return &gfc_bad_expr;
+ }
for (i = 0; i < rank; i++)
{
gcc_assert (order[i] >= 1 && order[i] <= rank);
order[i]--;
- gcc_assert (x[order[i]] == 0);
+ if (x[order[i]] != 0)
+ {
+ gfc_error ("ORDER at %L is not a permutation of the size of "
+ "SHAPE at %L", &order_exp->where, &shape_exp->where);
+ return &gfc_bad_expr;
+ }
x[order[i]] = 1;
}
}
+2019-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/91565
+ * gfortran.dg/pr91565.f90: New test.
+
2019-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91564
--- /dev/null
+! { dg-do compile }
+! PR fortran/91565
+! Contributed by Gerhard Steinmetz
+program p
+ integer, parameter :: a(2) = [2,2] ! { dg-error "\(1\)" }
+ print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "not a permutation" }
+end
+
+subroutine foo
+ integer, parameter :: a(1) = 1 ! { dg-error "\(1\)" }
+ print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "are different" }
+end
+
+subroutine bar
+ integer, parameter :: a(1,2) = 1 ! { dg-error "\(1\)" }
+ print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "are different" }
+end