]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/45081 (ICE in gfc_conv_array_initializer, at fortran/trans-array.c...
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 9 Dec 2010 08:09:52 +0000 (08:09 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 9 Dec 2010 08:09:52 +0000 (09:09 +0100)
2010-12-09  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/45081
        * simplify.c (is_constant_array_expr): Allow structure array
        elements as well as constants.
        (gfc_simplify_reshape): Copy the derived type of source to
        the result.

2010-12-09  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/45081
        * gfortran.dg/derived_array_intrinsics_1.f90 : New test.

From-SVN: r167627

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

index 01d88fc84bde69b127c4220131322a680567f3d4..86770ae8d495ef2ab8a50ab48650c478303065d5 100644 (file)
@@ -1,3 +1,11 @@
+2010-12-09  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/45081
+       * simplify.c (is_constant_array_expr): Allow structure array
+       elements as well as constants.
+       (gfc_simplify_reshape): Copy the derived type of source to
+       the result.
+
 2010-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
index 8b84d65f8e877c5871b66a7fe9c765c929fe4705..3688c8f031e956412453b85e49843b59e512e20b 100644 (file)
@@ -3448,7 +3448,8 @@ is_constant_array_expr (gfc_expr *e)
     return false;
   
   for (c = e->value.constructor; c; c = c->next)
-    if (c->expr->expr_type != EXPR_CONSTANT)
+    if (c->expr->expr_type != EXPR_CONSTANT
+         && c->expr->expr_type != EXPR_STRUCTURE)
       return false;
 
   return true;
@@ -3679,6 +3680,11 @@ inc:
   e->ts = source->ts;
   e->rank = rank;
 
+  if (source->ts.type == BT_CHARACTER)
+    e->ts.cl = source->ts.cl;
+  else if (source->ts.type == BT_DERIVED)
+    e->ts.derived = source->ts.derived;
+
   return e;
 
 bad_reshape:
index f65d67d21d78b3e16d1acaa6aa41e1d523d662c3..427920942b8a1f67ebe6eb9078e1b9cf1df8836a 100644 (file)
@@ -1,8 +1,13 @@
+2010-12-09  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/45081
+       * gfortran.dg/derived_array_intrinsics_1.f90 : New test.
+
 2010-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
        2010-11-20  Jakub Jelinek  <jakub@redhat.com>
+
        PR c++/46538
        * g++.dg/other/error34.C: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/derived_array_intrinisics_1.f90 b/gcc/testsuite/gfortran.dg/derived_array_intrinisics_1.f90
new file mode 100644 (file)
index 0000000..7d8bbce
--- /dev/null
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+! Test the fix for PR45081 in which derived type array valued intrinsics failed
+! to simplify, which caused an ICE in trans-array.c
+!
+! Contributed by Thorsten Ohl <ohl@physik.uni-wuerzburg.de>
+! 
+! Modified for GCC 4.4, which does not support (UN)PACK, TRANSPOSE or SPEAD
+! as initialization expressions.
+
+  module m
+    implicit none
+    integer :: i
+    type t
+      integer :: i
+    end type t
+    type(t), dimension(4), parameter :: t1  = [( t(i), i = 1, 4)]
+    type(t), dimension(4), parameter :: t2  = [( t(i), i = 8, 11)]
+    type(t), dimension(2,2), parameter :: a = reshape ( t1, [ 2, 2 ] )
+    type(t), dimension(2,2), parameter :: b = a !transpose (a)
+    type(t), dimension(4), parameter :: c = reshape ( b, [ 4 ] )
+    type(t), dimension(2), parameter :: d = c([2,4]) !pack ( c, [.false.,.true.,.false.,.true.])
+    type(t), dimension(4), parameter :: e = c !unpack (d, [.false.,.true.,.false.,.true.], t2)
+    type(t), dimension(4,2), parameter :: f = reshape([c,c],[4,2]) !spread (e, 2, 2)
+    type(t), dimension(8), parameter :: g = reshape ( f, [ 8 ] )
+    integer, parameter :: total = g(3)%i
+  end module m
+
+    use m
+    integer :: j
+    j = total
+  end
+! { dg-final { scan-tree-dump-times "j = 3" 1 "original" } }