Based on a report by bd satish at http://gcc.gnu.org/ml/fortran/2010-06/msg00210.html The following program is invalid as IMPORT is missing, but gfortran still compiles it: Expected: An error such as: Error: line 12: SELF is of undefined derived type CONNECTION or error #6457: This derived type name has not been declared. [CONNECTION] module factory_pattern implicit none type, abstract :: Connection contains procedure(generic_desc), deferred :: description end type Connection abstract interface subroutine generic_desc(self) ! import class(Connection) :: self end subroutine generic_desc end interface end module factory_pattern
Cf. also PR 44616 for the ICE reported at the mailing list.
Confirmed. Changing the CLASS statement into TYPE gives the correct error: type(Connection) :: self 1 Error: the type of 'self' at (1) has not been declared within the interface
Simple patch. Janus, if you have time, you can create a full patch out of it. Index: decl.c =================================================================== --- decl.c (revision 161227) +++ decl.c (working copy) @@ -1764,7 +1764,7 @@ variable_decl (int elem) specified in the procedure definition, except that the interface may specify a procedure that is not pure if the procedure is defined to be pure(12.3.2). */ - if (current_ts.type == BT_DERIVED + if ((current_ts.type == BT_DERIVED || current_ts.type == BT_CLASS) && gfc_current_ns->proc_name && gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY && current_ts.u.derived->ns != gfc_current_ns)
Subject: Bug 44614 Author: burnus Date: Thu Jun 24 07:51:22 2010 New Revision: 161310 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161310 Log: 2010-06-24 Tobias Burnus <burnus@net-b.de> PR fortran/44614 * decl.c (variable_decl): Fix IMPORT diagnostic for CLASS. 2010-06-24 Tobias Burnus <burnus@net-b.de> PR fortran/44614 * gfortran.dg/import8.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/import8.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk (4.6).