OSDN Git Service

2008-10-04 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Oct 2008 05:50:00 +0000 (05:50 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 5 Oct 2008 05:50:00 +0000 (05:50 +0000)
PR fortran/37706
* module.c (load_equiv): Check the module before negating the
unused flag.

2008-10-04  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/37706
* gfortran.dg/module_equivalence_4.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140879 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/module.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/module_equivalence_4.f90 [new file with mode: 0644]

index 869cd89..d462da0 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-04  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/37706
+       * module.c (load_equiv): Check the module before negating the
+       unused flag.
+
 2008-10-02  Steven Bosscher  <steven@gcc.gnu.org>
 
        PR fortran/37635
index 762114c..3846d95 100644 (file)
@@ -3806,11 +3806,14 @@ load_equiv (void)
        mio_expr (&tail->expr);
       }
 
-    /* Unused equivalence members have a unique name.  */
+    /* Unused equivalence members have a unique name.  In addition, it
+       must be checked that the symbol is that from the module.  */
     unused = true;
     for (eq = head; eq; eq = eq->eq)
       {
-       if (!check_unique_name (eq->expr->symtree->name))
+       if (eq->expr->symtree->n.sym->module
+             && strcmp (module_name, eq->expr->symtree->n.sym->module) == 0
+             && !check_unique_name (eq->expr->symtree->name))
          {
            unused = false;
            break;
index c0687c9..c0b275c 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-04  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/37706
+       * gfortran.dg/module_equivalence_4.f90: New test.
+
 2008-10-04  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/ssa-pre-21.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/module_equivalence_4.f90 b/gcc/testsuite/gfortran.dg/module_equivalence_4.f90
new file mode 100644 (file)
index 0000000..7a8ef9c
--- /dev/null
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! This checks the fix for PR37706 in which the equivalence would be
+! inserted into the 'nudata' namespace with the inevitable consequences.
+!
+! Contributed by Lester Petrie <petrielmjr@ornl.gov>
+!
+module data_C 
+    integer, dimension(200) :: l  = (/(201-i, i = 1,200)/)
+    integer :: l0
+    integer :: l24, l27, l28, l29
+    equivalence ( l(1), l0 )
+  end module data_C 
+
+subroutine nudata(nlibe, a, l) 
+  USE data_C, only:  l24, l27, l28, l29
+  implicit none
+  integer  :: nlibe 
+  integer  :: l(*) 
+  real :: a(*)
+  print *, l(1), l(2)
+  return  
+end subroutine nudata
+      
+  integer  :: l_(2) = (/1,2/), nlibe_ = 42
+  real :: a_(2) = (/1.,2./)  
+  call nudata (nlibe_, a_, l_)
+end
+
+! { dg-final { cleanup-modules "data_C" } }