[Patch, Fortran, OOP] PR 79311: ICE in generate_finalization_wrapper, at fortran/class.c:1992
Janus Weil
janus@gcc.gnu.org
Mon May 8 21:16:00 GMT 2017
Hi all,
the attached patch fixes an ICE-on-valid problem with finalization by
making sure that the finalization procedures are properly resolved.
In the test case, the finalizer of the component type was not being
resolved if the superordinate type had a finalizer itself.
The patch also fixes a small error that had no actual impact on the
test case ('has_final2' could never become true).
Regtesting went well, except for these three failure which also seems
to occur on a clean trunk currently:
FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
FAIL: gfortran.dg/coarray_lock_7.f90 -O scan-tree-dump-times original
FAIL: gfortran.dg/mvbits_7.f90 -O0 (test for warnings, line 28)
Ok for trunk?
Cheers,
Janus
2017-05-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/79311
* resolve.c (gfc_resolve_finalizers): Ensure that derived-type
components have a their finalizers resolved, also if the superordinate
type itself has a finalizer.
2017-05-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/79311
* gfortran.dg/finalize_32.f90: New test.
-------------- next part --------------
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 247757)
+++ gcc/fortran/resolve.c (working copy)
@@ -12385,26 +12385,23 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool
if (parent)
gfc_resolve_finalizers (parent, finalizable);
- /* Return early when not finalizable. Additionally, ensure that derived-type
- components have a their finalizables resolved. */
- if (!derived->f2k_derived || !derived->f2k_derived->finalizers)
+ /* Ensure that derived-type components have a their finalizers resolved. */
+ bool has_final = derived->f2k_derived && derived->f2k_derived->finalizers;
+ for (c = derived->components; c; c = c->next)
+ if (c->ts.type == BT_DERIVED
+ && !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable)
+ {
+ bool has_final2 = false;
+ if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final2))
+ return false; /* Error. */
+ has_final = has_final || has_final2;
+ }
+ /* Return early if not finalizable. */
+ if (!has_final)
{
- bool has_final = false;
- for (c = derived->components; c; c = c->next)
- if (c->ts.type == BT_DERIVED
- && !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable)
- {
- bool has_final2 = false;
- if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final))
- return false; /* Error. */
- has_final = has_final || has_final2;
- }
- if (!has_final)
- {
- if (finalizable)
- *finalizable = false;
- return true;
- }
+ if (finalizable)
+ *finalizable = false;
+ return true;
}
/* Walk over the list of finalizer-procedures, check them, and if any one
-------------- next part --------------
A non-text attachment was scrubbed...
Name: finalize_32.f90
Type: text/x-fortran
Size: 578 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20170508/8b3244f4/attachment.bin>
More information about the Fortran
mailing list