This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to gfortran PR 15314


This program causes ICE because the initialization
code switches on type of the initialization expression, instead
of field type.  Since 123 is a scalar, it does not invoke
the array initialization function.  The fix follows.

program main

  type foo
     integer :: a(10) = 123
     integer :: b = 456
  end type foo

  type(foo) :: x
  print*, x%b
end

--- trans-expr.c.orig   2004-05-06 14:45:39.000000000 +0300
+++ trans-expr.c        2004-05-06 15:29:39.000000000 +0300
@@ -1291,22 +1291,17 @@ gfc_conv_structure (gfc_se * se, gfc_exp
       gfc_init_se (&cse, se);
       /* Evaluate the expression for this component.  */
       if (init)
-       {
-         switch (c->expr->expr_type)
-           {
-           case EXPR_ARRAY:
-             arraytype = TREE_TYPE (cm->backend_decl);
-             cse.expr = gfc_conv_array_initializer (arraytype, c->expr);
-             break;
-
-           case EXPR_STRUCTURE:
-             gfc_conv_structure (&cse, c->expr, 1);
-             break;
-
-           default:
-             gfc_conv_expr (&cse, c->expr);
-           }
-       }
+        {
+          if (cm->dimension)
+            {
+              arraytype = TREE_TYPE (cm->backend_decl);
+              cse.expr = gfc_conv_array_initializer (arraytype, c->expr);
+            }
+          else if (cm->ts.type == BT_DERIVED)
+            gfc_conv_structure (&cse, c->expr, 1);
+          else
+            gfc_conv_expr (&cse, c->expr);
+        }
       else
        {
          gfc_conv_expr (&cse, c->expr);

-- 
  Victor Leikehman
  IBM Research Labs in Haifa, Israel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]