From: Mikael Morin Date: Mon, 24 Nov 2008 19:04:34 +0000 (+0100) Subject: re PR fortran/38184 (invariant RESHAPE not expanded if SOURCE is empty) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e7cc036d23e3eba474a083d8b1348b9252ff870;p=platform%2Fupstream%2Fgcc.git re PR fortran/38184 (invariant RESHAPE not expanded if SOURCE is empty) 2008-11-24 Mikael Morin PR fortran/38184 * simplify.c (is_constant_array_expr): Return true instead of false if the array constructor is empty. 2008-11-24 Mikael Morin PR fortran/38184 * gfortran.dg/reshape_empty_1.f03: New test. From-SVN: r142168 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8a00921..5fe6e9e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-11-24 Mikael Morin + + PR fortran/38184 + * simplify.c (is_constant_array_expr): Return true instead of false + if the array constructor is empty. + 2008-11-24 Daniel Kraft PR fortran/37779 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 34105bc..7922bde 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3410,9 +3410,6 @@ is_constant_array_expr (gfc_expr *e) if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e)) return false; - if (e->value.constructor == NULL) - return false; - for (c = e->value.constructor; c; c = c->next) if (c->expr->expr_type != EXPR_CONSTANT) return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff142cb..7d040e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-24 Mikael Morin + + PR fortran/38184 + * gfortran.dg/reshape_empty_1.f03: New test. + 2008-11-24 Jack Howarth PR testsuite/38241 diff --git a/gcc/testsuite/gfortran.dg/reshape_empty_1.f03 b/gcc/testsuite/gfortran.dg/reshape_empty_1.f03 new file mode 100644 index 0000000..cac7e73 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/reshape_empty_1.f03 @@ -0,0 +1,20 @@ +! { dg-do run } +! { dg-options "-fdump-tree-original" } +! +! PR fortran/38184 +! invariant RESHAPE not expanded if SOURCE is empty. +! +! Original program by James Van Buskirk + +integer, parameter :: N = 3 +integer, parameter :: A(N,N) = reshape([integer::],[N,N],reshape([1],[N+1],[2])) +integer, parameter :: K = N*A(2,2)+A(2,3) +integer :: B(N,N) = reshape([1,2,2,2,1,2,2,2,1],[3,3]) +integer :: i +i = 5 +if (any(A /= B)) call abort +if (K /= i) call abort +end + +! { dg-final { scan-tree-dump-times "\\\{1, 2, 2, 2, 1, 2, 2, 2, 1\\\}" 2 "original" } } +! { dg-final { cleanup-tree-dump "original" } }