diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 3c0355a1c39..66e7d9ff50e 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -1556,6 +1556,8 @@ merge_default_template_args (tree new_parms, tree old_parms, bool class_p) tree old_parm = TREE_VALUE (TREE_VEC_ELT (old_parms, i)); tree& new_default = TREE_PURPOSE (TREE_VEC_ELT (new_parms, i)); tree& old_default = TREE_PURPOSE (TREE_VEC_ELT (old_parms, i)); + if (error_operand_p (new_parm) || error_operand_p (old_parm)) + return false; if (new_default != NULL_TREE && old_default != NULL_TREE) { auto_diagnostic_group d; diff --git a/gcc/testsuite/g++.dg/template/pr108206.C b/gcc/testsuite/g++.dg/template/pr108206.C new file mode 100644 index 00000000000..9362d261bea --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr108206.C @@ -0,0 +1,5 @@ +// PR c++/108206 +// { dg-do compile { target c++11 } } + +template void foo (T1); // { dg-error "'X' has not been declared" } +template void foo (T2); // { dg-error "'X' has not been declared" }