diff options
author | jlquinn <jlquinn@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-30 12:20:38 +0000 |
---|---|---|
committer | jlquinn <jlquinn@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-30 12:20:38 +0000 |
commit | a8b9b12cce0d3fa3fbfb225d52185feec4cd6587 (patch) | |
tree | c8414dbd8e4600cf712301416289369549cd3f46 /gcc/cp/mangle.c | |
parent | 59094ddc19203ff44fdacecc52737a8af473c6f8 (diff) | |
download | gcc-a8b9b12cce0d3fa3fbfb225d52185feec4cd6587.tar.gz |
2009-10-30 Jerry Quinn <jlquinn@optonline.net>
* libsupc++/tinfo.cc (operator=(const type_info&)): Revert 153734.
* libsupc++/typeinfo (type_info::name()): Likewise.
* libsupc++/tinfo2.cc (before): Likewise.
2009-10-30 Jerry Quinn <jlquinn@optonline.net>
* mangle.c (mangle_type_string_for_rtti): Revert 153734.
(needs_fake_anon): Likewise.
(write_name): Likewise.
(write_nested_name): Likewise.
* cp-tree.h (mangle_type_string_for_rtti): Likewise.
(get_anonymous_namespace): Likewise.
* name-lookup.c (get_anonymous_namespace_name): Likewise.
* rtti.c (tinfo_name): Likewise.
(tinfo_base_init): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153742 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/mangle.c')
-rw-r--r-- | gcc/cp/mangle.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 7489665bfa8..874df748f81 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -105,6 +105,10 @@ typedef struct GTY(()) globals { static GTY (()) globals G; +/* Whether or not to pretend that a static function is in an anonymous + namespace. */ +static bool fake_anon_scope; + /* The obstack on which we build mangled names. */ static struct obstack *mangle_obstack; @@ -730,6 +734,20 @@ write_encoding (const tree decl) } } +/* Since we now use strcmp to compare typeinfos on all targets because of + the RTLD_LOCAL problem, we need to munge the typeinfo name used for + local classes of static functions to fix g++.dg/abi/local1.C. We do + that by pretending that the function is in an anonymous namespace. */ + +static bool +needs_fake_anon (const_tree decl) +{ + /* Pretend there's an anonymous namespace right around a static + function if we're mangling for RTTI. */ + return (fake_anon_scope && !TREE_PUBLIC (decl) + && TREE_CODE (decl) == FUNCTION_DECL); +} + /* Lambdas can have a bit more context for mangling, specifically VAR_DECL or PARM_DECL context, which doesn't belong in DECL_CONTEXT. */ @@ -773,13 +791,18 @@ write_name (tree decl, const int ignore_local_scope) context = decl_mangling_context (decl); + gcc_assert (context != NULL_TREE); + + /* If we need a fake anonymous namespace, force the nested name path. */ + if (needs_fake_anon (decl) && context == global_namespace) + context = error_mark_node; + /* A decl in :: or ::std scope is treated specially. The former is mangled using <unscoped-name> or <unscoped-template-name>, the latter with a special substitution. Also, a name that is directly in a local function scope is also mangled with <unscoped-name> rather than a full <nested-name>. */ - if (context == NULL - || context == global_namespace + if (context == global_namespace || DECL_NAMESPACE_STD_P (context) || (ignore_local_scope && TREE_CODE (context) == FUNCTION_DECL)) { @@ -797,6 +820,9 @@ write_name (tree decl, const int ignore_local_scope) } else { + if (context == error_mark_node) + context = global_namespace; + /* Handle local names, unless we asked not to (that is, invoked under <local-name>, to handle only the part of the name under the local scope). */ @@ -809,10 +835,10 @@ write_name (tree decl, const int ignore_local_scope) directly in that function's scope, either decl or one of its enclosing scopes. */ tree local_entity = decl; - while (context != NULL && context != global_namespace) + while (context != global_namespace) { /* Make sure we're always dealing with decls. */ - if (context != NULL && TYPE_P (context)) + if (TYPE_P (context)) context = TYPE_NAME (context); /* Is this a function? */ if (TREE_CODE (context) == FUNCTION_DECL @@ -857,7 +883,6 @@ write_unscoped_name (const tree decl) /* If not, it should be either in the global namespace, or directly in a local function scope. */ gcc_assert (context == global_namespace - || context != NULL || TREE_CODE (context) == FUNCTION_DECL); write_unqualified_name (decl); @@ -929,6 +954,9 @@ write_nested_name (const tree decl) { /* No, just use <prefix> */ write_prefix (DECL_CONTEXT (decl)); + if (needs_fake_anon (decl)) + /* Pretend this static function is in an anonymous namespace. */ + write_source_name (get_anonymous_namespace_name ()); write_unqualified_name (decl); } write_char ('E'); @@ -2984,15 +3012,18 @@ mangle_decl (const tree decl) SET_DECL_ASSEMBLER_NAME (decl, id); } -/* Generate the mangled representation of TYPE. */ +/* Generate the mangled representation of TYPE for the typeinfo name. */ const char * -mangle_type_string (const tree type) +mangle_type_string_for_rtti (const tree type) { const char *result; start_mangling (type); + /* Mangle in a fake anonymous namespace if necessary. */ + fake_anon_scope = true; write_type (type); + fake_anon_scope = false; result = finish_mangling (/*warn=*/false); if (DEBUG_MANGLE) fprintf (stderr, "mangle_type_string = '%s'\n\n", result); |