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.
|| 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;
--- /dev/null
+// PR c++/97511
+// { dg-do compile { target c++11 } }
+
+template <class Z> using Z = Z; // { dg-error "shadow|declaration" }