I've committed the following patch.  It restores gfortran's
behavior prior to my commit r224159 if the current namespace
has an empty equivalent list.

2016-09-09  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/77420
        * module.c (load_equiv): If the current namespace has a list of
        equivalence statements, initialize duplicate to false and then
        look for duplicates; otherwise, initialize it to true.
 
2016-09-09  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/77420
        * gfortran.dg/pr77420.f90: New test.


Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c        (revision 240057)
+++ gcc/fortran/module.c        (working copy)
@@ -4647,7 +4647,7 @@ load_equiv (void)
       }
 
     /* Check for duplicate equivalences being loaded from different modules */
-    duplicate = false;
+    duplicate = gfc_current_ns->equiv ? false:true;
     for (equiv = gfc_current_ns->equiv; equiv; equiv = equiv->next)
       {
        if (equiv->module && head->module
Index: gcc/testsuite/gfortran.dg/pr77420.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr77420.f90       (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr77420.f90       (working copy)
@@ -0,0 +1,18 @@
+! { dg-do compile }
+MODULE test_equivalence
+  REAL, PRIVATE, DIMENSION(100) :: array1
+  REAL, PRIVATE, DIMENSION(100) :: array2
+  EQUIVALENCE(array1(1),array2(1))
+END MODULE test_equivalence
+
+MODULE mymodule
+  USE test_equivalence
+  ! declare a local variable with the same name as the (private!)
+  ! variable in module test_equivalence:
+  REAL, DIMENSION(:), ALLOCATABLE :: array1
+END MODULE mymodule
+
+PROGRAM test
+  USE mymodule
+END PROGRAM test
+
-- 
Steve

Reply via email to