[Patch, Fortran, OOP] PR 80392: [5/6/7 Regression] ICE with allocatable polymorphic function result in a procedure pointer component
Janus Weil
janus@gcc.gnu.org
Mon Apr 17 09:08:00 GMT 2017
Hi all,
the attached patch fixes an ICE-on-valid regression, where the
compiler runs into an infinite loop if a derived type contains a
procedure-pointer component which has a polymorphic result of the
original type.
We already have a piece of code which prevents the infinite loop for
TYPE-valued PPCs, but it doesn't work for CLASS results, which is
fixed by the patch here.
Ok for trunk and the 5/6 branches?
Cheers,
Janus
2017-04-17 Janus Weil <janus@gcc.gnu.org>
PR fortran/80392
* trans-types.c (gfc_get_derived_type): Prevent an infinite loop when
building a derived type that includes a procedure pointer component
with a polymorphic result.
2017-04-17 Janus Weil <janus@gcc.gnu.org>
PR fortran/80392
* gfortran.dg/proc_ptr_comp_49.f90: New test case.
-------------- next part --------------
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c (revision 246939)
+++ gcc/fortran/trans-types.c (working copy)
@@ -2617,9 +2617,10 @@ gfc_get_derived_type (gfc_symbol * derived, int co
the same as derived, by forcing the procedure pointer component to
be built as if the explicit interface does not exist. */
if (c->attr.proc_pointer
- && ((c->ts.type != BT_DERIVED && c->ts.type != BT_CLASS)
- || (c->ts.u.derived
- && !gfc_compare_derived_types (derived, c->ts.u.derived))))
+ && (c->ts.type != BT_DERIVED || (c->ts.u.derived
+ && !gfc_compare_derived_types (derived, c->ts.u.derived)))
+ && (c->ts.type != BT_CLASS || (CLASS_DATA (c)->ts.u.derived
+ && !gfc_compare_derived_types (derived, CLASS_DATA (c)->ts.u.derived))))
field_type = gfc_get_ppc_type (c);
else if (c->attr.proc_pointer && derived->backend_decl)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_comp_49.f90
Type: text/x-fortran
Size: 392 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20170417/92958710/attachment.bin>
More information about the Fortran
mailing list