c++: ICE mangling C auto... tparm [PR124297]

After r16-7491, the constraint on a C auto... tparm is represented as a
fold-expression (in TEMPLATE_PARM_CONSTRAINTS) instead of a concept-id (in
PLACEHOLDER_TYPE_CONSTRAINTS).  So we now need to strip this fold-expression
before calling write_type_constraint, like we do in the type template
parameter case a few lines below.

	PR c++/124297

gcc/cp/ChangeLog:

	* mangle.cc (write_template_param_decl) <case PARM_DECL>:
	Strip fold-expression before calling write_type_constraint.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-variadic4.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
This commit is contained in:
Patrick Palka
2026-03-06 17:59:11 -05:00
parent 5eecb51ad7
commit d0d3d4dde0
2 changed files with 17 additions and 0 deletions

View File

@@ -1927,6 +1927,11 @@ write_template_param_decl (tree parm)
? TEMPLATE_PARM_CONSTRAINTS (parm)
: NULL_TREE))
{
if (TREE_CODE (c) == UNARY_LEFT_FOLD_EXPR)
{
c = FOLD_EXPR_PACK (c);
c = PACK_EXPANSION_PATTERN (c);
}
if (AUTO_IS_DECLTYPE (type))
write_string ("DK");
else

View File

@@ -0,0 +1,12 @@
// PR c++/124297
// { dg-do compile { target c++20 } }
template<class T> concept C = true;
template<C auto... Vs> void f();
int main() {
f<42>();
}
// { dg-final { scan-assembler "_Z1fITpTnDk1CJLi42EEEvv" } }