(duplicate_decls): Properly merge decls with differing DECL_CONTEXT.
authorRichard Kenner <kenner@gcc.gnu.org>
Fri, 11 Nov 1994 22:53:39 +0000 (17:53 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 11 Nov 1994 22:53:39 +0000 (17:53 -0500)
From-SVN: r8428

gcc/c-decl.c

index 995009a4635423607ce577bbea3641cd49368552..427ff3a7d37a2ce2f06a3307107158e2be0d107a 100644 (file)
@@ -1698,11 +1698,16 @@ duplicate_decls (newdecl, olddecl)
            make_var_volatile (newdecl);
        }
 
-      /* Keep source location of definition rather than declaration.  */
-      if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
+      /* Keep source location of definition rather than declaration.
+        Likewise, keep decl at outer scope.  */
+      if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
+         || (DECL_CONTEXT (newdecl) != 0 && DECL_CONTEXT (olddecl) == 0))
        {
          DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
          DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
+
+         if (DECL_CONTEXT (olddecl) == 0)
+           DECL_CONTEXT (newdecl) = 0;
        }
 
       /* Merge the unused-warning information.  */