This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR39688: IMPORT of derived type fails


Dear all,

here is my fix for PR39688, which is a problem with a derived type
being IMPORTed into an interface, where the type has been use-renamed
before. The patch is as compact as can be and regtests fine on
x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2009-04-24  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/39688
	* decl.c (gfc_match_import): Use 'sym->name' instead of 'name'.
	They differ if the symbol has been use-renamed.


2009-04-24  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/39688
	* gfortran.dg/import7.f90: New.
Index: gcc/testsuite/gfortran.dg/import7.f90
===================================================================
--- gcc/testsuite/gfortran.dg/import7.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/import7.f90	(Revision 0)
@@ -0,0 +1,58 @@
+! { dg-do compile }
+!
+! PR39688: IMPORT of derived type fails
+!
+! Contributed by Bob Corbett <robert.corbett@sun.com>
+
+       MODULE MOD
+         TYPE T1
+           SEQUENCE
+           TYPE(T2), POINTER :: P
+         END TYPE
+         TYPE T2
+           SEQUENCE
+           INTEGER I
+         END TYPE
+       END
+
+       PROGRAM MAIN
+         USE MOD, T3 => T1, T4 => T2
+         TYPE T1
+           SEQUENCE
+           TYPE(T2), POINTER :: P
+         END TYPE
+         INTERFACE SUBR
+           SUBROUTINE SUBR1(X)
+             IMPORT T3
+             TYPE(T3) X
+           END SUBROUTINE
+           SUBROUTINE SUBR2(X)
+             IMPORT T1
+             TYPE(T1) X
+           END SUBROUTINE
+         END INTERFACE
+         TYPE T2
+           SEQUENCE
+           REAL X
+         END TYPE
+       END
+
+       SUBROUTINE SUBR1(X)
+         USE MOD
+         TYPE(T1) X
+       END
+
+       SUBROUTINE SUBR2(X)
+         TYPE T1
+           SEQUENCE
+           TYPE(T2), POINTER :: P
+         END TYPE
+         TYPE T2
+           SEQUENCE
+           REAL X
+         END TYPE
+         TYPE(T1) X
+       END
+
+! { dg-final { cleanup-modules "mod" } }
+
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(Revision 146676)
+++ gcc/fortran/decl.c	(Arbeitskopie)
@@ -2741,7 +2741,7 @@ gfc_match_import (void)
 	      goto next_item;
 	    }
 
-	  st = gfc_new_symtree (&gfc_current_ns->sym_root, name);
+	  st = gfc_new_symtree (&gfc_current_ns->sym_root, sym->name);
 	  st->n.sym = sym;
 	  sym->refs++;
 	  sym->attr.imported = 1;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]