re PR fortran/34083 (internal compiler error: in gfc_conv_array_constructor_expr...
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 21 Nov 2007 18:32:40 +0000 (18:32 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 21 Nov 2007 18:32:40 +0000 (18:32 +0000)
PR fortran/34083

* resolve.c (resolve_structure_cons): Also check for zero rank.

* gfortran.dg/derived_constructor_comps_2.f90: Add check.

From-SVN: r130332

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/derived_constructor_comps_2.f90

index e6e5990fd3818a64d3a934966baec5ae60e09f9d..74e5df01bb7f3d130be304b4c386980f24a8831f 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-21  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/34083
+       * resolve.c (resolve_structure_cons): Also check for zero rank.
+
 2007-11-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/33317
index 6c9856d5f62aea1719cab8b074ab2166caaa9a0a..c6808eb1f216b18246d7a7b4c0c04ebff82bd5f7 100644 (file)
@@ -742,6 +742,8 @@ resolve_structure_cons (gfc_expr *expr)
 
   for (; comp; comp = comp->next, cons = cons->next)
     {
+      int rank;
+
       if (!cons->expr)
        continue;
 
@@ -751,14 +753,14 @@ resolve_structure_cons (gfc_expr *expr)
          continue;
        }
 
-      if (cons->expr->expr_type != EXPR_NULL
-         && comp->as && comp->as->rank != cons->expr->rank
+      rank = comp->as ? comp->as->rank : 0;
+      if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
          && (comp->allocatable || cons->expr->rank))
        {
          gfc_error ("The rank of the element in the derived type "
                     "constructor at %L does not match that of the "
                     "component (%d/%d)", &cons->expr->where,
-                    cons->expr->rank, comp->as ? comp->as->rank : 0);
+                    cons->expr->rank, rank);
          t = FAILURE;
        }
 
index 19f65a94ed55c1f31b4a33b530ab8850e00f96b4..ff241baebf651d999d76ca13591f776924909f0c 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-21  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/34083
+       * gfortran.dg/derived_constructor_comps_2.f90: Add check.
+
 2007-11-20  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/34154
index f69e10064132b50374d1a1339f80555b2fb5b402..ef3005da294ccaf6f9ade49440d1d63e3dc84aaf 100644 (file)
   marge = homer (duff_beer) ! { dg-error "should be a POINTER or a TARGET" }
 end
 
+!
+! The following yield an ICE, see PR 34083
+!
+subroutine foo
+  type ByteType
+    character(len=1) :: singleByte
+  end type
+  type (ByteType) :: bytes(4)
+
+  print *, size(bytes)
+  bytes = ByteType((/'H', 'i', '!', ' '/)) ! { dg-error "rank of the element in the derived type constructor" }
+end subroutine foo