From: Steven G. Kargl Date: Thu, 10 Oct 2019 21:56:08 +0000 (+0000) Subject: re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733) X-Git-Tag: releases/gcc-9.3.0~560 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2031db034b6e7ad2d144166b4aa99356bcf39c;p=thirdparty%2Fgcc.git re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733) 2019-10-10 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-10 Steven G. Kargl PR fortran/91801 * gfortran.dg/pr91801.f90: New test. From-SVN: r276853 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 12c7221335af..34df830bb20e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-10 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-07 Thomas Koenig Backport from trunk diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index f8c9a42cdc7f..58b4652b0100 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6745,7 +6745,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 bbd614a286ee..f63e0a1910c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-10 Steven G. Kargl + + PR fortran/91801 + * gfortran.dg/pr91801.f90: New test. + 2019-10-10 Uroš Bizjak PR target/92022 diff --git a/gcc/testsuite/gfortran.dg/pr91801.f90 b/gcc/testsuite/gfortran.dg/pr91801.f90 new file mode 100644 index 000000000000..d2d82b88464b --- /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