From: Steven G. Kargl Date: Tue, 2 Jun 2015 22:08:14 +0000 (+0000) Subject: simplify.c (gfc_simplify_reshape): Convert assert into returning NULL, which triggers... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4cb2a41df2b4871e6c0596b2b6683788cda6e04;p=gcc.git simplify.c (gfc_simplify_reshape): Convert assert into returning NULL, which triggers an error condition. 2015-06-02 Steven G. Kargl * simplify.c (gfc_simplify_reshape): Convert assert into returning NULL, which triggers an error condition. 2015-06-02 Steven G. Kargl * gfortran.dg/reshape_7.f90: New test. From-SVN: r224043 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6be535f4948..944139eb706 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-06-02 Steven G. Kargl + + * simplify.c (gfc_simplify_reshape): Convert assert into returning + NULL, which triggers an error condition. + 2015-05-27 Andre Vehreschild PR fortran/65548 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index f49c6c08851..2f3e247cd08 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70a05dae193..a86359de2af 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-06-02 Steven G. Kargl + + * gfortran.dg/reshape_7.f90: New test. + 2015-06-02 David Malcolm 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 index 00000000000..6e17f198d11 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/reshape_7.f90 @@ -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