aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2019-10-10 21:56:08 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2019-10-10 21:56:08 +0000
commitee4d2790e101b8314cc9c5528ed1c7e3d49814bc (patch)
treeb78dcea99f093b7ee753675df0e808f83ece457f
parentb47b41cb29f54ee8ad2b1c71fdb58de7dc75eaec (diff)
2019-10-10 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-10 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/91801 * gfortran.dg/pr91801.f90: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@276853 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/simplify.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr91801.f907
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 12c7221335a..34df830bb20 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2019-10-10 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-07 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index f8c9a42cdc7..58b4652b010 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 bbd614a286e..f63e0a1910c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-10 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/91801
+ * gfortran.dg/pr91801.f90: New test.
+
2019-10-10 Uroš Bizjak <ubizjak@gmail.com>
PR target/92022
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