aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/testsuite/g++.dg/template/shadow3.C4
2 files changed, 7 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;
diff --git a/gcc/testsuite/g++.dg/template/shadow3.C b/gcc/testsuite/g++.dg/template/shadow3.C
new file mode 100644
index 0000000..a5f2563
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/shadow3.C
@@ -0,0 +1,4 @@
+// PR c++/97511
+// { dg-do compile { target c++11 } }
+
+template <class Z> using Z = Z; // { dg-error "shadow|declaration" }