diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index bfd16e1ef62..169e6a62f5f 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -20041,7 +20041,16 @@ cp_parser_placeholder_type_specifier (cp_parser *parser, location_t loc, /* In a template parameter list, a type-parameter can be introduced by type-constraints alone. */ if (processing_template_parmlist && !placeholder) - return build_constrained_parameter (con, proto, args); + { + /* In a default argument we may not be creating new parameters. */ + if (parser->local_variables_forbidden_p & LOCAL_VARS_FORBIDDEN) + { + /* If this assert turns out to be false, do error() instead. */ + gcc_assert (tentative); + return error_mark_node; + } + return build_constrained_parameter (con, proto, args); + } /* Diagnose issues placeholder issues. */ if (!flag_concepts_ts diff --git a/gcc/testsuite/g++.dg/concepts/variadic6.C b/gcc/testsuite/g++.dg/concepts/variadic6.C new file mode 100644 index 00000000000..0b386b0cd6d --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/variadic6.C @@ -0,0 +1,20 @@ +// PR c++/105268 +// { dg-do compile { target concepts } } + +template concept C_one = true; +template concept C_many = true; + +template struct S { }; + +template>> void f(); +template>> void g(); + +void +fn (auto a = S>{}) +{ +} + +void +fn2 (auto a = S>{}) +{ +}