]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use the local name instead of the original name in the check for name conflicts...
authorMikael Morin <mikael@gcc.gnu.org>
Fri, 13 Feb 2015 19:33:27 +0000 (19:33 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Fri, 13 Feb 2015 19:33:27 +0000 (19:33 +0000)
Use the local name instead of the original name in the check for name conflicts
between a hosting program unit and use-associated symbols
in that program unit.

fortran/
    PR fortran/63744
    * module.c (check_for_ambiguous): Change argument type
    from gfc_symbol to gfc_symtree.  Check local (symtree) name
    instead of original (symbol) name.
    (read_module): Update caller.

testsuite/
    PR fortran/63744
    gfortran.dg/use_rename_8.f90: New.

From-SVN: r220692

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

index 81c4c1d860e454696bf32cf47d272656f9d5f427..176d943c786b35f9677e1e293084470573494c9f 100644 (file)
@@ -1,3 +1,11 @@
+2015-02-13  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/63744
+       * module.c (check_for_ambiguous): Change argument type
+       from gfc_symbol to gfc_symtree.  Check local (symtree) name
+       instead of original (symbol) name.
+       (read_module): Update caller.
+
 2015-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index c267ee7d6109945f87963d05a7b270d85ad74e85..4fd0d883c8465fe9c9540b71778b643df5226cc3 100644 (file)
@@ -4401,19 +4401,21 @@ read_cleanup (pointer_info *p)
 /* It is not quite enough to check for ambiguity in the symbols by
    the loaded symbol and the new symbol not being identical.  */
 static bool
-check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info)
+check_for_ambiguous (gfc_symtree *st, pointer_info *info)
 {
   gfc_symbol *rsym;
   module_locus locus;
   symbol_attribute attr;
+  gfc_symbol *st_sym;
 
-  if (gfc_current_ns->proc_name && st_sym->name == gfc_current_ns->proc_name->name)
+  if (gfc_current_ns->proc_name && st->name == gfc_current_ns->proc_name->name)
     {
       gfc_error ("'%s' of module '%s', imported at %C, is also the name of the "
-                "current program unit", st_sym->name, module_name);
+                "current program unit", st->name, module_name);
       return true;
     }
 
+  st_sym = st->n.sym;
   rsym = info->u.rsym.sym;
   if (st_sym == rsym)
     return false;
@@ -4648,7 +4650,7 @@ read_module (void)
          if (st != NULL)
            {
              /* Check for ambiguous symbols.  */
-             if (check_for_ambiguous (st->n.sym, info))
+             if (check_for_ambiguous (st, info))
                st->ambiguous = 1;
              else
                info->u.rsym.symtree = st;
index 5ecad07979b6bc876a98670b98dff6c7d2c22ed0..ff0934bb381138b2eea29b969915e47d5aa3252e 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-13  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/63744
+       gfortran.dg/use_rename_8.f90: New.
+
 2015-02-12  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/gfortran.dg/use_rename_8.f90 b/gcc/testsuite/gfortran.dg/use_rename_8.f90
new file mode 100644 (file)
index 0000000..ad3ab39
--- /dev/null
@@ -0,0 +1,50 @@
+! { dg-do compile }
+!
+! PR fortran/63744
+! duplicate use rename used to be rejected when the target name
+! was that of the current program unit 
+!
+! Original testcase from Roger Ferrer Ibanez <roger.ferrer@bsc.es>
+
+MODULE MOO
+    INTEGER :: A, B, C, D, E, F, G, H, I
+END MODULE MOO
+
+SUBROUTINE S
+    USE MOO, ONLY: X => A, X => A
+END SUBROUTINE S
+
+SUBROUTINE T
+    USE MOO, ONLY: X => B
+    USE MOO, ONLY: X => B
+END SUBROUTINE T
+
+SUBROUTINE C
+    USE MOO, ONLY: C  ! { dg-error "is also the name of the current program unit" }
+END SUBROUTINE C
+
+SUBROUTINE D
+    USE MOO, ONLY: X => D
+END SUBROUTINE D
+
+SUBROUTINE E
+    USE MOO, ONLY: X => E, X => E
+END SUBROUTINE E
+
+SUBROUTINE F
+    USE MOO, ONLY: X => F
+    USE MOO, ONLY: X => F
+END SUBROUTINE F
+
+SUBROUTINE X
+    USE MOO, ONLY: X => G ! { dg-error "is also the name of the current program unit" }
+END SUBROUTINE X
+
+SUBROUTINE Y
+    USE MOO, ONLY: Y => H ! { dg-error "is also the name of the current program unit" }
+END SUBROUTINE Y
+
+SUBROUTINE Z
+    USE MOO, ONLY: Z => I, Z => I ! { dg-error "is also the name of the current program unit" }
+END SUBROUTINE Z
+