aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-11-02 10:24:16 -0800
committerNathan Sidwell <nathan@acm.org>2020-11-02 10:34:31 -0800
commit9757d793f800a9ea1e35977b7e9e68d6f293e857 (patch)
treef397ce912bf959d30e5f7f9d2dd78479fdbe6e54 /gcc
parentf915e19e62a81b46c613b4d665e1d38ceee16991 (diff)
downloadgcc-9757d793f800a9ea1e35977b7e9e68d6f293e857.zip
gcc-9757d793f800a9ea1e35977b7e9e68d6f293e857.tar.gz
gcc-9757d793f800a9ea1e35977b7e9e68d6f293e857.tar.bz2
c++: refactor duplicate decls
A couple of paths in duplicate decls dealing with templates and builtins were overly complicated. Fixing thusly. gcc/cp/ * decl.c (duplicate_decls): Refactor some template & builtin handling.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 39f56b8..3846e82 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2471,22 +2471,27 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
DECL_NOT_REALLY_EXTERN (newdecl) |= DECL_NOT_REALLY_EXTERN (olddecl);
DECL_COMDAT (newdecl) |= DECL_COMDAT (olddecl);
}
- DECL_TEMPLATE_INSTANTIATED (newdecl)
- |= DECL_TEMPLATE_INSTANTIATED (olddecl);
- DECL_ODR_USED (newdecl) |= DECL_ODR_USED (olddecl);
- /* If the OLDDECL is an instantiation and/or specialization,
- then the NEWDECL must be too. But, it may not yet be marked
- as such if the caller has created NEWDECL, but has not yet
- figured out that it is a redeclaration. */
- if (!DECL_USE_TEMPLATE (newdecl))
- DECL_USE_TEMPLATE (newdecl) = DECL_USE_TEMPLATE (olddecl);
+ if (TREE_CODE (newdecl) != TYPE_DECL)
+ {
+ DECL_TEMPLATE_INSTANTIATED (newdecl)
+ |= DECL_TEMPLATE_INSTANTIATED (olddecl);
+ DECL_ODR_USED (newdecl) |= DECL_ODR_USED (olddecl);
+
+ /* If the OLDDECL is an instantiation and/or specialization,
+ then the NEWDECL must be too. But, it may not yet be marked
+ as such if the caller has created NEWDECL, but has not yet
+ figured out that it is a redeclaration. */
+ if (!DECL_USE_TEMPLATE (newdecl))
+ DECL_USE_TEMPLATE (newdecl) = DECL_USE_TEMPLATE (olddecl);
+
+ DECL_INITIALIZED_IN_CLASS_P (newdecl)
+ |= DECL_INITIALIZED_IN_CLASS_P (olddecl);
+ }
/* Don't really know how much of the language-specific
values we should copy from old to new. */
DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl);
- DECL_INITIALIZED_IN_CLASS_P (newdecl)
- |= DECL_INITIALIZED_IN_CLASS_P (olddecl);
if (LANG_DECL_HAS_MIN (newdecl))
{
@@ -2646,19 +2651,20 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)
{
enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl);
- switch (fncode)
+ if (builtin_decl_explicit_p (fncode))
{
- /* If a compatible prototype of these builtin functions
- is seen, assume the runtime implements it with the
- expected semantics. */
- case BUILT_IN_STPCPY:
- if (builtin_decl_explicit_p (fncode))
- set_builtin_decl_implicit_p (fncode, true);
- break;
- default:
- if (builtin_decl_explicit_p (fncode))
- set_builtin_decl_declared_p (fncode, true);
- break;
+ /* A compatible prototype of these builtin functions
+ is seen, assume the runtime implements it with
+ the expected semantics. */
+ switch (fncode)
+ {
+ case BUILT_IN_STPCPY:
+ set_builtin_decl_implicit_p (fncode, true);
+ break;
+ default:
+ set_builtin_decl_declared_p (fncode, true);
+ break;
+ }
}
copy_attributes_to_builtin (newdecl);