[Patch, fortran] PR43945 - [OOP] Derived type with GENERIC: resolved to the wrong specific TBP
Janus Weil
janus@gcc.gnu.org
Fri Jun 4 23:46:00 GMT 2010
2010/5/17 Tobias Burnus <burnus@net-b.de>:
>> It is interesting if one follows "class_ref" in
>> resolve_typebound_subroutine. Before
>> resolve_typebound_call (code, &name);
>> it is still "type = REF_COMPONENT" but afterwards it is type = 2893287512.
>>
>
> Which makes sense:
>
> resolve_typebound_subroutine (gfc_code *code)
> {
> declared = get_declared_from_expr (&class_ref, &new_ref, code->expr1);
> resolve_typebound_call (code, &name);
> if (class_ref)
>
> and
>
> resolve_typebound_call (gfc_code* c, const char **name)
> {
> gfc_free_expr (c->expr1);
>
> Thus, it is not surprising that it won't work if one frees c->expr1 -
> and then uses c->expr1->ref == class_ref later.
... which means we should probably just forget about the
"gfc_free_ref_list", since the whole expression has already been
freed. Adding the following to Paul's patch makes the ICEs go away:
@@ -5423,11 +5443,8 @@ resolve_typebound_function (gfc_expr* e)
e->value.function.esym = NULL;
e->symtree = st;
- if (class_ref)
- {
- gfc_free_ref_list (class_ref->next);
- e->ref = new_ref;
- }
+ if (new_ref)
+ e->ref = new_ref;
/* '$vptr' points to the vtab, which contains the procedure pointers. */
gfc_add_component_ref (e, "$vptr");
@@ -5496,11 +5513,8 @@ resolve_typebound_subroutine (gfc_code *code)
code->expr1->value.function.esym = NULL;
code->expr1->symtree = st;
- if (class_ref)
- {
- gfc_free_ref_list (class_ref->next);
- code->expr1->ref = new_ref;
- }
+ if (new_ref)
+ code->expr1->ref = new_ref;
/* '$vptr' points to the vtab, which contains the procedure pointers. */
gfc_add_component_ref (code->expr1, "$vptr");
The full patch can be found in the attachment. It regtests without
failures. Paul, do you think this is ok? If yes, should I go ahead and
commit it?
Cheers,
Janus
More information about the Gcc-patches
mailing list