From edb4c415dc1288c0137de8fa0cbb8a36376223c3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 27 Aug 2000 21:44:28 -0400 Subject: [PATCH] c-decl.c (duplicate_decls): Don't set TREE_STATIC or clear DECL_EXTERNAL on a local extern. * 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. From-SVN: r36012 --- gcc/ChangeLog | 7 +++++++ gcc/c-decl.c | 32 ++++++++++++-------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fba2d7d179b..14ade14d0c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2000-08-27 Jason Merrill + + * 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 * ABOUT-GCC-NLS: Remove gettext patches from Paul Eggert as diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 2e336f4fde7..5404a4ffbe2 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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. */ -- 2.30.2