This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45577] [4.6 Regression] Bogus(?) "... type incompatible with source-expr ..." error
- From: "janus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Sep 2010 22:34:37 -0000
- Subject: [Bug fortran/45577] [4.6 Regression] Bogus(?) "... type incompatible with source-expr ..." error
- References: <bug-45577-12313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from janus at gcc dot gnu dot org 2010-09-07 22:34 -------
Here is a better patch:
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 163946)
+++ gcc/fortran/resolve.c (working copy)
@@ -6727,10 +6727,16 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code
if (ts.type == BT_CLASS)
ts = ts.u.derived->components->ts;
- if (ts.type == BT_DERIVED)
+ if (ts.type == BT_DERIVED && gfc_has_default_initializer(ts.u.derived))
{
- code->expr3 = gfc_default_initializer (&ts);
- gfc_resolve_expr (code->expr3);
+ gfc_expr *init_e = gfc_default_initializer (&ts);
+ gfc_code *init_st = gfc_get_code ();
+ init_st->loc = code->loc;
+ init_st->op = EXEC_INIT_ASSIGN;
+ init_st->expr1 = gfc_expr_to_initialize (e);
+ init_st->expr2 = init_e;
+ init_st->next = code->next;
+ code->next = init_st;
}
}
else if (code->expr3->mold && code->expr3->ts.type == BT_DERIVED)
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2010-09-07 10:26:48 |2010-09-07 22:34:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45577