diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-10-08 16:31:16 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-10-08 16:31:16 +0000 |
commit | 8cad1ad5ade3fac0a2a796361bf5400d5f385036 (patch) | |
tree | 142cfba8a2c03d3725b73088a5d0d1b125ab797f /gcc | |
parent | ff2640e58c4f0dfdb71b1828295f5c186a9685da (diff) | |
download | gcc-8cad1ad5ade3fac0a2a796361bf5400d5f385036.zip gcc-8cad1ad5ade3fac0a2a796361bf5400d5f385036.tar.gz gcc-8cad1ad5ade3fac0a2a796361bf5400d5f385036.tar.bz2 |
re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733)
2019-10-08 Steven G. Kargl <kargl@gcc.gnu.org>
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 <kargl@gcc.gnu.org>
PR fortran/91801
* gfortran.dg/pr91801.f90: New test.
From-SVN: r276706
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr91801.f90 | 7 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b5bef54..7847042 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-08 Steven G. Kargl <kargl@gcc.gnu.org> + + 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 <tobias@codesourcery.com> * parse.c (parse_executable): Add missing ST_OMP_TARGET_SIMD. diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 8c1577e..fa5aefe 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 f3da169..cad47cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-08 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91801 + * gfortran.dg/pr91801.f90: New test. + 2019-10-08 Marek Polacek <polacek@redhat.com> 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 0000000..d2d82b8 --- /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 |