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]

Re: [Patch, Fortran] PR fortran/37193: USE m, ONLY: i, j => i


Paul Richard Thomas wrote:
Daniel,

It's a lovely patch but I think it's the wrong one:-)

Tobias and Paul, indeed it is :) This one is probably much easier to understand :P


Cheers,
Daniel

--
Done:     Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go:    Hea-Kni-Mon-Pri-Ran-Rog-Tou
2008-08-30  Daniel Kraft  <d@domob.eu>

	PR fortran/37193
	* module.c (read_module): Initialize use_only flag on used symbols.

2008-08-30  Daniel Kraft  <d@domob.eu>

	PR fortran/37193
	* gfortran.dg/use_rename_4.f90: New test.
	* gfortran.dg/use_rename_5.f90: New test.
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 139801)
+++ gcc/fortran/module.c	(working copy)
@@ -4052,9 +4052,9 @@ read_module (void)
 	      st = gfc_find_symtree (gfc_current_ns->sym_root, name);
 
 	      /* Delete the symtree if the symbol has been added by a USE
-		 statement without an ONLY(11.3.2). Remember that the rsym
+		 statement without an ONLY(11.3.2).  Remember that the rsym
 		 will be the same as the symbol found in the symtree, for
-		 this case.*/
+		 this case.  */
 	      if (st && (only_flag || info->u.rsym.renamed)
 		     && !st->n.sym->attr.use_only
 		     && !st->n.sym->attr.use_rename
@@ -4089,6 +4089,7 @@ read_module (void)
 
 	      if (strcmp (name, p) != 0)
 		sym->attr.use_rename = 1;
+	      sym->attr.use_only = only_flag;
 
 	      /* Store the symtree pointing to this symbol.  */
 	      info->u.rsym.symtree = st;
Index: gcc/testsuite/gfortran.dg/use_rename_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/use_rename_4.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/use_rename_4.f90	(revision 0)
@@ -0,0 +1,22 @@
+! { dg-do run }
+
+! PR fortran/37193
+! Check fix for problem with re-using the same symbol both renamed and
+! plain.
+
+MODULE m
+  IMPLICIT NONE
+  INTEGER :: i
+END MODULE m
+
+PROGRAM main
+  USE m, ONLY: i, j => i
+  IMPLICIT NONE
+
+  i = 4
+  j = 5
+
+  IF (i /= j) THEN
+    CALL abort ()
+  END IF
+END PROGRAM main
Index: gcc/testsuite/gfortran.dg/use_rename_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/use_rename_5.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/use_rename_5.f90	(revision 0)
@@ -0,0 +1,17 @@
+! { dg-do compile }
+
+! PR fortran/37193
+! Check that renamed symbols are not accessiable uner their target name.
+
+MODULE m
+  IMPLICIT NONE
+  INTEGER :: i
+END MODULE m
+
+PROGRAM main
+  USE m, ONLY: j => i
+  IMPLICIT NONE
+
+  i = 4 ! { dg-error "no IMPLICIT type" }
+  j = 5
+END PROGRAM main

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