Bug 44616 - [OOP] ICE if CLASS(foo) is used before its definition
[OOP] ICE if CLASS(foo) is used before its definition
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.6.0
: P3 normal
: ---
Assigned To: janus
: ice-on-valid-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-21 16:43 UTC by Tobias Burnus
Modified: 2010-06-22 17:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-06-21 18:30:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-06-21 16:43:39 UTC
Reported by bd satish at http://gcc.gnu.org/ml/fortran/2010-06/msg00210.html

For the program, gfortran ICEs with:
  f951: internal compiler error: in find_typebound_proc_uop, at
  fortran/class.c:660

The failing assert is:
  gcc_assert (derived->f2k_derived);

Note: The original test case (see link) misses an IMPORT, cf. PR 44614.

The additional derived type is required -- and for the ICE it needs to come before the actual definition, otherwise, it works.

module factory_pattern
implicit none

type First_Factory
    character(len=20) :: factory_type
    class(Connection), pointer :: connection_type
    contains
end type First_Factory

type, abstract :: Connection
    contains
    procedure(generic_desc), deferred :: description
end type Connection

abstract interface
    subroutine generic_desc(self)
        import  ! Required, cf. PR 44614
        class(Connection) :: self
    end subroutine generic_desc
end interface
end module factory_pattern
Comment 1 janus 2010-06-21 18:30:07 UTC
Here is a fix:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 161045)
+++ gcc/fortran/resolve.c       (working copy)
@@ -11136,6 +11136,7 @@ resolve_fl_derived (gfc_symbol *sym)
   /* If this is a non-ABSTRACT type extending an ABSTRACT one, ensure that
      all DEFERRED bindings are overridden.  */
   if (super_type && super_type->attr.abstract && !sym->attr.abstract
+      && !sym->attr.is_class
       && ensure_not_abstract (sym, super_type) == FAILURE)
     return FAILURE;
 
Comment 2 janus 2010-06-22 17:07:30 UTC
Subject: Bug 44616

Author: janus
Date: Tue Jun 22 17:07:06 2010
New Revision: 161208

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161208
Log:
2010-06-22  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/44616
	* resolve.c (resolve_fl_derived): Avoid checking for abstract on class
	containers.

2010-06-22  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/44616
	* gfortran.dg/abstract_type_8.f03: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/abstract_type_8.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 janus 2010-06-22 17:09:13 UTC
Fixed with r161208. Closing.