diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-10-22 07:27:55 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-10-22 07:27:55 -0400 |
commit | b083a14dfe1f53446722f488885078e419238d24 (patch) | |
tree | 26ea671b1e995beb0a517ab7e66d868f97de8974 /gcc/cp/decl.c | |
parent | 03e93e1efebc12d9fba1a2a9cdcb3c12ecfec642 (diff) | |
download | gcc-b083a14dfe1f53446722f488885078e419238d24.zip gcc-b083a14dfe1f53446722f488885078e419238d24.tar.gz gcc-b083a14dfe1f53446722f488885078e419238d24.tar.bz2 |
c++: Check DECL_TEMPLATE_PARM_P in duplicate_decls [PR97511]
This makes duplicate_decls differentiate a TYPE_DECL for an alias
template from a TYPE_DECL for one of its template parameters. The
recently added assert in template_parm_to_arg revealed this latent issue
because merging of the two TYPE_DECLs cleared the DECL_TEMPLATE_PARM_P
flag.
With this patch, we now also correctly diagnose the name shadowing in
the below testcase (as required by [temp.local]/6).
gcc/cp/ChangeLog:
PR c++/97511
* decl.c (duplicate_decls): Return NULL_TREE if
DECL_TEMPLATE_PARM_P differ.
gcc/testsuite/ChangeLog:
PR c++/97511
* g++.dg/template/shadow3.C: New test.
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5f370e6..2de4e16 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2002,6 +2002,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) || DECL_IMPLICIT_TYPEDEF_P (newdecl))) return NULL_TREE; + if (DECL_TEMPLATE_PARM_P (olddecl) != DECL_TEMPLATE_PARM_P (newdecl)) + return NULL_TREE; + if (!validate_constexpr_redeclaration (olddecl, newdecl)) return error_mark_node; |