[Bug fortran/80392] [5/6/7 Regression] [OOP] ICE with allocatable polymorphic function result in a procedure pointer component

2017-04-14 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80392

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
  Known to work||4.8.5
Summary|ICE with allocatable|[5/6/7 Regression] [OOP]
   |polymorphic function result |ICE with allocatable
   |in a procedure pointer  |polymorphic function result
   |component   |in a procedure pointer
   ||component
  Known to fail||4.9.4, 5.4.1, 6.3.0, 7.0

--- Comment #2 from janus at gcc dot gnu.org ---
(In reply to zed.three from comment #0)
> With gfortran 7.0.1, I get an ICE:
> 
> gfortran-7: internal compiler error: Segmentation fault (program f951)
> 
> I also get an ICE with 5.4.1 and 6.2.1 (but not 4.8.5) if I remove the
> `bad_sub` implementation.

Right. This is clearly an ICE-on-valid regression:

module mwe

  implicit none

  type :: MyType
 procedure(my_op), nopass, pointer :: op
  end type

contains

  function my_op() result(foo)
class(MyType), allocatable :: foo
  end function

end module

[Bug fortran/80392] [5/6/7 Regression] [OOP] ICE with allocatable polymorphic function result in a procedure pointer component

2017-04-15 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80392

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |janus at gcc dot gnu.org

--- Comment #3 from janus at gcc dot gnu.org ---
We already have a check to prevent this kind of infinite recursion (as shown in
comment #1) in gfc_get_derived_type, however it is apparently only working for
TYPEs, but not for CLASSes. This patch should fix it (and makes comment #0 and
comment #2 compile fine with trunk):

Index: gcc/fortran/trans-types.c
===
--- gcc/fortran/trans-types.c   (revision 246933)
+++ 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)
{


Regtesting now ...

[Bug fortran/80392] [5/6/7 Regression] [OOP] ICE with allocatable polymorphic function result in a procedure pointer component

2017-04-15 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80392

--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to janus from comment #3)
> Regtesting now ...

Regtest completed successfully ...

[Bug fortran/80392] [5/6/7 Regression] [OOP] ICE with allocatable polymorphic function result in a procedure pointer component

2017-04-19 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80392

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P4
 CC||law at redhat dot com
   Target Milestone|--- |7.0