]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/91801 (ICE in gfc_simplify_reshape, at fortran/simplify.c:6733)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 10 Oct 2019 21:56:08 +0000 (21:56 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 10 Oct 2019 21:56:08 +0000 (21:56 +0000)
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.

From-SVN: r276853

gcc/fortran/ChangeLog
gcc/fortran/simplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr91801.f90 [new file with mode: 0644]

index 12c7221335afda1e0c610fe3e8f4dcbd9b57d88a..34df830bb20eb3c7ae3613d98d88a3bb8cd54a0e 100644 (file)
@@ -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
index f8c9a42cdc7f2461fbd8c2fef8887a120a729143..58b4652b01007020bb5e3504ff77b3827c991342 100644 (file)
@@ -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)
            {
index bbd614a286ee9d9d3c8c5870279cc778c133098a..f63e0a1910c8dfb64d2c988123c7b9973e3af991 100644 (file)
@@ -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 (file)
index 0000000..d2d82b8
--- /dev/null
@@ -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