diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-11-16 14:54:54 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-11-16 14:54:54 +0000 |
commit | 5f3682ffcef162363b783eb9ee702debff489fa8 (patch) | |
tree | b9e4f1042a3c4558c07ba463d34ee29d68c28a6e /gcc/cp | |
parent | a930324dabd41a76ef141a85a7d0cc7fc9c9c0b3 (diff) | |
download | gcc-5f3682ffcef162363b783eb9ee702debff489fa8.zip gcc-5f3682ffcef162363b783eb9ee702debff489fa8.tar.gz gcc-5f3682ffcef162363b783eb9ee702debff489fa8.tar.bz2 |
[PATCH] New lang hook
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01340.html
PR c++/82836
PR c++/82737
* tree.h (COPY_DECL_RTL): Rename parms for clarity.
(SET_DECL_ASSEMBLER_NAME): Forward to
overwrite_decl_assembler_name.
(COPY_DECL_ASSEMBLER_NAME): Rename parms for clarity.
(overwrite_decl_assembler_name): Declare.
* tree.c (overwrite_decl_assembler_name): New.
* langhooks-def.h (lhd_overwrite_decl_assembler_name): Declare.
(LANG_HOOKS_OVERWRITE_DECL_ASSEMBLER_NAME): Provide default.
(LANG_HOOKS_INITIALIZER): Add it.
* langhooks.h (struct lang_hooks): Add overwrite_decl_assembler_name.
* langhooks.c (lhd_set_decl_assembler_name): Use
SET_DECL_ASSEMBLER_NAME.
(lhd_overwrite_decl_assembler_name): Default implementation.
PR c++/82836
PR c++/82737
* cp-objcp-common.h (LANG_HOOKS_OVERWRITE_DECL_ASSEMBLER_NAME):
Override.
* cp-tree.h (overwrite_mangling): Declare.
* decl2.c (struct mangled_decl_hash): Entries are deletable.
(overwrite_mangling): New.
PR c++/82836
PR c++/82737
* g++.dg/pr82836.C: New.
From-SVN: r254823
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 38 |
4 files changed, 46 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 31de2a6..9ceff2f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2017-11-16 Nathan Sidwell <nathan@acm.org> + PR c++/82836 + PR c++/82737 + * cp-objcp-common.h (LANG_HOOKS_OVERWRITE_DECL_ASSEMBLER_NAME): + Override. + * cp-tree.h (overwrite_mangling): Declare. + * decl2.c (struct mangled_decl_hash): Entries are deletable. + (overwrite_mangling): New. + PR c++/81060 * decl.c (xref_tag_1): Push lambda into current scope. * name-lookup.c (do_pushtag): Don't deal with ts_lambda here. diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 3e4cc9c..a1b1fcd 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -73,6 +73,8 @@ extern void cp_register_dumps (gcc::dump_manager *); #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME mangle_decl +#undef LANG_HOOKS_OVERWRITE_DECL_ASSEMBLER_NAME +#define LANG_HOOKS_OVERWRITE_DECL_ASSEMBLER_NAME overwrite_mangling #undef LANG_HOOKS_PRINT_STATISTICS #define LANG_HOOKS_PRINT_STATISTICS cxx_print_statistics #undef LANG_HOOKS_PRINT_XNODE diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6051348..c655416 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6187,6 +6187,7 @@ extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t); /* in decl2.c */ extern void record_mangling (tree, bool); +extern void overwrite_mangling (tree, tree); extern void note_mangling_alias (tree, tree); extern void generate_mangling_aliases (void); extern tree build_memfn_type (tree, tree, cp_cv_quals, cp_ref_qualifier); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0b18308..bc0db00 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -123,9 +123,14 @@ struct mangled_decl_hash : ggc_remove <tree> static inline void mark_empty (value_type &p) {p = NULL_TREE;} static inline bool is_empty (value_type p) {return !p;} - /* Nothing is deletable. Everything is insertable. */ - static bool is_deleted (value_type) { return false; } - static void mark_deleted (value_type) { gcc_unreachable (); } + static bool is_deleted (value_type e) + { + return e == reinterpret_cast <value_type> (1); + } + static void mark_deleted (value_type &e) + { + e = reinterpret_cast <value_type> (1); + } }; /* A hash table of decls keyed by mangled name. Used to figure out if @@ -4439,6 +4444,33 @@ record_mangling (tree decl, bool need_warning) } } +/* The mangled name of DECL is being forcibly changed to NAME. Remove + any existing knowledge of DECL's mangled name meaning DECL. */ + +void +overwrite_mangling (tree decl, tree name) +{ + if (tree id = DECL_ASSEMBLER_NAME_RAW (decl)) + if ((TREE_CODE (decl) == VAR_DECL + || TREE_CODE (decl) == FUNCTION_DECL) + && mangled_decls) + if (tree *slot + = mangled_decls->find_slot_with_hash (id, IDENTIFIER_HASH_VALUE (id), + NO_INSERT)) + if (*slot == decl) + { + mangled_decls->clear_slot (slot); + + /* If this is an alias, remove it from the symbol table. */ + if (DECL_ARTIFICIAL (decl) && DECL_IGNORED_P (decl)) + if (symtab_node *n = symtab_node::get (decl)) + if (n->cpp_implicit_alias) + n->remove (); + } + + DECL_ASSEMBLER_NAME_RAW (decl) = name; +} + /* The entire file is now complete. If requested, dump everything to a file. */ |