diff options
author | Jason Merrill <jason@redhat.com> | 2011-07-22 15:59:49 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-07-22 15:59:49 -0400 |
commit | 3a636414b2c73cb405796d4faf35640897258413 (patch) | |
tree | 316fb84969a5bd89637c30710f3f154a8baf6605 /gcc/c-family/c-pragma.c | |
parent | 8b9b22755b5c98bfe292f3cf73bba6c53acc47c9 (diff) | |
download | gcc-3a636414b2c73cb405796d4faf35640897258413.zip gcc-3a636414b2c73cb405796d4faf35640897258413.tar.gz gcc-3a636414b2c73cb405796d4faf35640897258413.tar.bz2 |
re PR c++/30112 (pragma redefine_extname fails when namespaces are involved)
PR c++/30112
gcc/c-family/
* c-common.h: Declare c_linkage_bindings.
* c-pragma.c (handle_pragma_redefine_extname): Use it.
gcc/
* c-decl.c (c_linkage_bindings): Define.
gcc/cp/
* decl.c (cp_finish_decl): Apply pragma redefine_extname in
other namespaces as well.
* name-lookup.c (c_linkage_bindings): Define.
(lookup_extern_c_fun_in_all_ns): Rename from
lookup_extern_c_fun_binding_in_all_ns. Return tree.
(pushdecl_maybe_friend_1): Adjust. Copy DECL_ASSEMBLER_NAME.
Co-Authored-By: Mark Glisse <marc.glisse@normalesup.org>
From-SVN: r176650
Diffstat (limited to 'gcc/c-family/c-pragma.c')
-rw-r--r-- | gcc/c-family/c-pragma.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 93735aa..5c8bc1f 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -417,8 +417,9 @@ static void handle_pragma_redefine_extname (cpp_reader *); static void handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) { - tree oldname, newname, decl, x; + tree oldname, newname, decls, x; enum cpp_ttype t; + bool found; if (pragma_lex (&oldname) != CPP_NAME) GCC_BAD ("malformed #pragma redefine_extname, ignored"); @@ -428,26 +429,42 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) if (t != CPP_EOF) warning (OPT_Wpragmas, "junk at end of %<#pragma redefine_extname%>"); - decl = identifier_global_value (oldname); - if (decl - && (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) - && (TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == VAR_DECL) - && has_c_linkage (decl)) + found = false; + for (decls = c_linkage_bindings (oldname); + decls; ) { - if (DECL_ASSEMBLER_NAME_SET_P (decl)) + tree decl; + if (TREE_CODE (decls) == TREE_LIST) { - const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - name = targetm.strip_name_encoding (name); - - if (strcmp (name, IDENTIFIER_POINTER (newname))) - warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " - "conflict with previous rename"); + decl = TREE_VALUE (decls); + decls = TREE_CHAIN (decls); } else - change_decl_assembler_name (decl, newname); + { + decl = decls; + decls = NULL_TREE; + } + + if ((TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) + && (TREE_CODE (decl) == FUNCTION_DECL + || TREE_CODE (decl) == VAR_DECL)) + { + found = true; + if (DECL_ASSEMBLER_NAME_SET_P (decl)) + { + const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + name = targetm.strip_name_encoding (name); + + if (strcmp (name, IDENTIFIER_POINTER (newname))) + warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " + "conflict with previous rename"); + } + else + change_decl_assembler_name (decl, newname); + } } - else + + if (!found) /* We have to add this to the rename list even if there's already a global value that doesn't meet the above criteria, because in C++ "struct foo {...};" puts "foo" in the current namespace but |