This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to gfortran PR 15314
- From: Victor Leikehman <lei at haifasphere dot co dot il>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 06 May 2004 15:46:54 +0300
- Subject: Patch to gfortran PR 15314
- Organization: IBM Research Lab in Haifa, Israel
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