re PR fortran/38184 (invariant RESHAPE not expanded if SOURCE is empty)
authorMikael Morin <mikael.morin@tele2.fr>
Mon, 24 Nov 2008 19:04:34 +0000 (20:04 +0100)
committerMikael Morin <mikael@gcc.gnu.org>
Mon, 24 Nov 2008 19:04:34 +0000 (19:04 +0000)
2008-11-24  Mikael Morin  <mikael.morin@tele2.fr>

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  <mikael.morin@tele2.fr>

PR fortran/38184
* gfortran.dg/reshape_empty_1.f03: New test.

From-SVN: r142168

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

index 8a00921..5fe6e9e 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-24  Mikael Morin  <mikael.morin@tele2.fr>
+
+       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  <d@domob.eu>
 
        PR fortran/37779
index 34105bc..7922bde 100644 (file)
@@ -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;
index ff142cb..7d040e1 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-24  Mikael Morin  <mikael.morin@tele2.fr>
+
+       PR fortran/38184
+       * gfortran.dg/reshape_empty_1.f03: New test.
+
 2008-11-24  Jack Howarth  <howarth@bromo.med.uc.edu>
 
        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 (file)
index 0000000..cac7e73
--- /dev/null
@@ -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" } }