diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-10-04 17:54:59 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-10-04 17:54:59 +0000 |
commit | e07b83663e961bdd8025e56e7916b72b3463b1c3 (patch) | |
tree | d5d394cf4cd8a033c411e8a75cdd6a12d39b79a7 /gcc | |
parent | d21f2166b03cfda6b689398f7839520d66123708 (diff) | |
download | gcc-e07b83663e961bdd8025e56e7916b72b3463b1c3.zip gcc-e07b83663e961bdd8025e56e7916b72b3463b1c3.tar.gz gcc-e07b83663e961bdd8025e56e7916b72b3463b1c3.tar.bz2 |
[C++ PATCH] give builtin types consistent name
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00201.html
Give builtin types the correct name.
* name-lookup.c (set_global_binding): Assert name is DECL_NAME.
* decl.c (record_builtin_type): Reimplement, use new TYPE_DECL for
rname.
From-SVN: r253426
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 52 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 1 |
3 files changed, 34 insertions, 26 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 035a1b7..277b646 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-10-04 Nathan Sidwell <nathan@acm.org> + + Give builtin types the correct name. + * name-lookup.c (set_global_binding): Assert name is DECL_NAME. + * decl.c (record_builtin_type): Reimplement, use new TYPE_DECL for + rname. + 2017-10-04 Paolo Carlini <paolo.carlini@oracle.com> Andrew Pinski <apinski@cavium.com> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ce45c11..99f0af2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3895,47 +3895,47 @@ make_unbound_class_template (tree context, tree name, tree parm_list, /* Push the declarations of builtin types into the global namespace. RID_INDEX is the index of the builtin type in the array RID_POINTERS. NAME is the name used when looking up the builtin - type. TYPE is the _TYPE node for the builtin type. */ + type. TYPE is the _TYPE node for the builtin type. + + The calls to SET_IDENTIFIER_GLOBAL_VALUE below should be + eliminated. Built-in types should not be looked up name; their + names are keywords that the parser can recognize. However, there + is code in c-common.c that uses identifier_global_value to look up + built-in types by name. */ void record_builtin_type (enum rid rid_index, const char* name, tree type) { - tree rname = NULL_TREE, tname = NULL_TREE; - tree tdecl = NULL_TREE; + tree decl = NULL_TREE; - if ((int) rid_index < (int) RID_MAX) - rname = ridpointers[(int) rid_index]; if (name) - tname = get_identifier (name); - - /* The calls to SET_IDENTIFIER_GLOBAL_VALUE below should be - eliminated. Built-in types should not be looked up name; their - names are keywords that the parser can recognize. However, there - is code in c-common.c that uses identifier_global_value to look - up built-in types by name. */ - if (tname) { - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type); + tree tname = get_identifier (name); + tree tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type); DECL_ARTIFICIAL (tdecl) = 1; SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl); + decl = tdecl; } - if (rname) - { - if (!tdecl) + + if ((int) rid_index < (int) RID_MAX) + if (tree rname = ridpointers[(int) rid_index]) + if (!decl || DECL_NAME (decl) != rname) { - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type); - DECL_ARTIFICIAL (tdecl) = 1; + tree rdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type); + DECL_ARTIFICIAL (rdecl) = 1; + SET_IDENTIFIER_GLOBAL_VALUE (rname, rdecl); + if (!decl) + decl = rdecl; } - SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl); - } - - if (!TYPE_NAME (type)) - TYPE_NAME (type) = tdecl; - if (tdecl) - debug_hooks->type_decl (tdecl, 0); + if (decl) + { + if (!TYPE_NAME (type)) + TYPE_NAME (type) = decl; + debug_hooks->type_decl (decl, 0); + } } /* Push a type into the namespace so that the back ends ignore it. */ diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 0111d8d..c72a7f4 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4847,6 +4847,7 @@ set_global_binding (tree name, tree val) { bool subtime = timevar_cond_start (TV_NAME_LOOKUP); + gcc_checking_assert (name == DECL_NAME (val)); tree *slot = find_namespace_slot (global_namespace, name, true); tree old = MAYBE_STAT_DECL (*slot); |