Patchwork [Fortran] PR 44614 Fix diagnostic for IMPORTing CLASS symbols

login
register
mail settings
Submitter Tobias Burnus
Date June 23, 2010, 9:38 p.m.
Message ID <4C227EC4.5000003@net-b.de>
Download mbox | patch
Permalink /patch/56728/
State New
Headers show

Comments

Tobias Burnus - June 23, 2010, 9:38 p.m.
gfortran did not diagnose the use of non-IMPORTed derived types, if they
were used as CLASS - it only diagnosed TYPE. The patch is on the verge
of being obvious.

Build and currently regtesting on x86-64-linux. If it succeeds:
OK for the trunk?

Tobias
Steve Kargl - June 23, 2010, 10:19 p.m.
On Wed, Jun 23, 2010 at 11:38:12PM +0200, Tobias Burnus wrote:
> gfortran did not diagnose the use of non-IMPORTed derived types, if they
> were used as CLASS - it only diagnosed TYPE. The patch is on the verge
> of being obvious.
> 
> Build and currently regtesting on x86-64-linux. If it succeeds:
> OK for the trunk?

OK.

Patch

2010-06-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/44614
	* decl.c (variable_decl): Fix IMPORT diagnostic for CLASS.

2010-06-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/44614
	* gfortran.dg/import8.f90: New.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(Revision 161288)
+++ gcc/fortran/decl.c	(Arbeitskopie)
@@ -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)
Index: gcc/testsuite/gfortran.dg/import8.f90
===================================================================
--- gcc/testsuite/gfortran.dg/import8.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/import8.f90	(Revision 0)
@@ -0,0 +1,18 @@ 
+! { dg-do compile }
+!
+! PR fortran/44614
+!
+!
+
+implicit none
+
+type, abstract :: Connection
+end type Connection
+
+abstract interface
+    subroutine generic_desc(self)
+        ! <<< missing IMPORT 
+        class(Connection) :: self ! { dg-error "has not been declared within the interface" }
+    end subroutine generic_desc
+end interface
+end