From: Steven G. Kargl Date: Tue, 8 Oct 2019 16:31:16 +0000 (+0000) Subject: re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8cad1ad5ade3fac0a2a796361bf5400d5f385036;p=gcc.git re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733) 2019-10-08 Steven G. Kargl PR fortran/91801 * simplify.c (gfc_simplify_reshape): Convert a gcc_assert into a gfc_error as a user can easily hit the condition. 2019-10-08 Steven G. Kargl PR fortran/91801 * gfortran.dg/pr91801.f90: New test. From-SVN: r276706 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b5bef54a297..784704293b9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-08 Steven G. Kargl + + PR fortran/91801 + * simplify.c (gfc_simplify_reshape): Convert a gcc_assert into a + gfc_error as a user can easily hit the condition. + 2019-10-08 Tobias Burnus * parse.c (parse_executable): Add missing ST_OMP_TARGET_SIMD. diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 8c1577ec269..fa5aefe20c6 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6762,7 +6762,15 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, gfc_extract_int (e, &order[i]); - gcc_assert (order[i] >= 1 && order[i] <= rank); + if (order[i] < 1 || order[i] > rank) + { + gfc_error ("Element with a value of %d in ORDER at %L must be " + "in the range [1, ..., %d] for the RESHAPE intrinsic " + "near %L", order[i], &order_exp->where, rank, + &shape_exp->where); + return &gfc_bad_expr; + } + order[i]--; if (x[order[i]] != 0) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3da169e2fe..cad47cc9219 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-08 Steven G. Kargl + + PR fortran/91801 + * gfortran.dg/pr91801.f90: New test. + 2019-10-08 Marek Polacek DR 685 - Integral promotion of enum ignores fixed underlying type. diff --git a/gcc/testsuite/gfortran.dg/pr91801.f90 b/gcc/testsuite/gfortran.dg/pr91801.f90 new file mode 100644 index 00000000000..d2d82b88464 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91801.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/91801 +! Code contributed by Gerhard Steinmetz +program p + integer, parameter :: a(2) = [2,0] ! { dg-error "Element with a value of" } + print *, reshape([1,2,3,4,5,6], [2,3], order=a) ! { dg-error "for the RESHAPE intrinsic near" } +end