simplify.c (gfc_simplify_reshape): Convert assert into returning NULL, which triggers...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 2 Jun 2015 22:08:14 +0000 (22:08 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 2 Jun 2015 22:08:14 +0000 (22:08 +0000)
2015-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

* simplify.c (gfc_simplify_reshape): Convert assert into returning
NULL, which triggers an error condition.

2015-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

* gfortran.dg/reshape_7.f90: New test.

From-SVN: r224043

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

index 6be535f49482406769331339382cd903604de9cf..944139eb7064ed3cb790baeb4f18509cb5b21ae1 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       * simplify.c (gfc_simplify_reshape): Convert assert into returning
+       NULL, which triggers an error condition.
+
 2015-05-27  Andre Vehreschild  <vehre@gmx.de>
 
        PR fortran/65548
index f49c6c08851e9720dff8aedda5387a9286891096..2f3e247cd083bd4db557650af71eb34339476487 100644 (file)
@@ -5188,8 +5188,11 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
        e = gfc_constructor_lookup_expr (source->value.constructor, j);
       else
        {
-         gcc_assert (npad > 0);
-
+         if (npad <= 0)
+           {
+             mpz_clear (index);
+             return NULL;
+           }
          j = j - nsource;
          j = j % npad;
          e = gfc_constructor_lookup_expr (pad->value.constructor, j);
index 70a05dae193a0f322847ff04d87f4548ef1718ab..a86359de2af53e486527250ed96f7361804e419f 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       * gfortran.dg/reshape_7.f90: New test.
+
 2015-06-02  David Malcolm  <dmalcolm@redhat.com>
 
        PR c/66220:
diff --git a/gcc/testsuite/gfortran.dg/reshape_7.f90 b/gcc/testsuite/gfortran.dg/reshape_7.f90
new file mode 100644 (file)
index 0000000..6e17f19
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! PR fortran/66380
+!
+subroutine p0
+   integer, parameter :: sh(2) = [2, 3]
+   integer, parameter :: &
+   & a(2,2) = reshape([1, 2, 3, 4], sh)   ! { dg-error "Different shape" }
+   if (a(1,1) /= 0) call abort
+end subroutine p0
+
+
+subroutine p1
+   integer, parameter :: sh(2) = [2, 1]
+   integer, parameter :: &
+   &  a(2,2) = reshape([1, 2, 3, 4], sh)  ! { dg-error "Different shape" }
+   if (a(1,1) /= 0) call abort
+end subroutine p1