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] | |
What if only comp's subcomponents are finalizable, the finalization wrapper should still be called, shouldn't it?Well, that's handled in the "else" branch. There, I walk all subcomponents. I do not need to walk them in case there is a finalizer as the called finalization wrapper will handle them.Actually, I don't understand why you walk twice over the subcomponents: in the else branch here and in the finalizer.
If comp has finalizable subcomponents, it has a finalization wrapper, which is (or should be) caught above, so this branch is (or should be) unreachable.I probably miss something, but I don't see why this branch should be unreachable. One has:
if (component is allocatable) call DEALLOCATE(comp) ! which might invoke finalizers else if (component itself has a finalizer) call FINAL_WRAPPER else for all nonpointer subcomponents which are allocatables, have finalizers or have allocatable/finalizable components, call finalize_component. end ifI expected something like: if (allocatable) call deallocate (comp) else if (finalizer or subcomponents have a finalizer) call FINAL_WRAPPER
As said above, I don't understand why you would walk over the components twice
Indeed, then I prefer having !CLASS_DATA(comp)->attr.pointer.Well, we do not deallocate/finalize polymorphic POINTER components.+ else if (comp->ts.type == BT_CLASS && CLASS_DATA (comp) + && CLASS_DATA (comp)->attr.allocatable) + alloc_comp = true;Shouldn't one assume without condition that there are allocatable or finalizable subcomponents when there is a polymorphic component?
bool has_final_comp(derived) {
for (comp = derived->components; comp; comp = comp->next)
{
if (comp->attr.pointer)
continue;
if (comp->f2k_derived->finalizers || comp->ts.type == BT_CLASS)
return true;
if (comp->ts.type == BT_DERIVED
&& has_final_comp(comp->ts.u.derived))
return true;
}
return false
}If performance is a problem, the function could use the flag as a backend. As long as the field is used and set in a single place, I don't mind. I don't have a strong opinion either, there is already a full bag of flags; one more wouldn't make things dramatically worse.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |