OSDN Git Service

* c-decl.c (duplicate_decls): Don't set TREE_STATIC or clear
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Aug 2000 01:44:28 +0000 (01:44 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Aug 2000 01:44:28 +0000 (01:44 +0000)
        DECL_EXTERNAL on a local extern.  Don't set DECL_IGNORED_P or
        TREE_ASM_WRITTEN, either.
        (finish_decl): Adjust.

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

gcc/ChangeLog
gcc/c-decl.c

index fba2d7d..14ade14 100644 (file)
@@ -1,3 +1,10 @@
+2000-08-27  Jason Merrill  <jason@redhat.com>
+
+       * c-decl.c (duplicate_decls): Don't set TREE_STATIC or clear
+       DECL_EXTERNAL on a local extern.  Don't set DECL_IGNORED_P or
+       TREE_ASM_WRITTEN, either.
+       (finish_decl): Adjust.
+
 2000-08-28  Philipp Thomas  <pthomas@suse.de>
 
        * ABOUT-GCC-NLS: Remove gettext patches from Paul Eggert as
index 2e336f4..5404a4f 100644 (file)
@@ -1947,8 +1947,14 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
     }
   if (DECL_EXTERNAL (newdecl))
     {
-      TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
-      DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
+      if (! different_binding_level)
+       {
+         /* Don't mess with these flags on local externs; they remain
+            external even if there's a declaration at file scope which
+            isn't.  */
+         TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
+         DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
+       }
       /* An extern decl does not override previous storage class.  */
       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
       if (! DECL_EXTERNAL (newdecl))
@@ -2007,19 +2013,7 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
        }
     }
   if (different_binding_level)
-    {
-      /* Don't output a duplicate symbol or debugging information for this
-        declaration.
-
-        Do not set TREE_ASM_WRITTEN for a FUNCTION_DECL since we may actually
-        just have two declarations without a definition.  VAR_DECLs may need
-        the same treatment, I'm not sure.  */
-      if (TREE_CODE (newdecl) == FUNCTION_DECL)
-       DECL_IGNORED_P (newdecl) = 1;
-      else
-       TREE_ASM_WRITTEN (newdecl) = DECL_IGNORED_P (newdecl) = 1;
-      return 0;
-    }
+    return 0;
 
   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
      But preserve OLDDECL's DECL_UID.  */
@@ -2370,7 +2364,8 @@ pushdecl (x)
                      DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
                      DECL_RESULT (x) = DECL_RESULT (oldglobal);
                      TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
-                     DECL_ABSTRACT_ORIGIN (x) = DECL_ORIGIN (oldglobal);
+                     DECL_ABSTRACT_ORIGIN (x)
+                       = DECL_ABSTRACT_ORIGIN (oldglobal);
                    }
                  /* Inner extern decl is built-in if global one is.  */
                  if (DECL_BUILT_IN (oldglobal))
@@ -3648,11 +3643,8 @@ finish_decl (decl, init, asmspec_tree)
                   Also if it is not file scope.
                   Otherwise, let it through, but if it is not `extern'
                   then it may cause an error message later.  */
-             /* A duplicate_decls call could have changed an extern
-                declaration into a file scope one.  This can be detected
-                by TREE_ASM_WRITTEN being set.  */
                (DECL_INITIAL (decl) != 0
-                || (DECL_CONTEXT (decl) != 0 && ! TREE_ASM_WRITTEN (decl)))
+                || DECL_CONTEXT (decl) != 0)
              :
                /* An automatic variable with an incomplete type
                   is an error.  */