On 3/3/26 11:06 AM, Patrick Palka wrote:
bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
OK for trunk?

OK.

-- >8 --

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.
---
  gcc/cp/mangle.cc                                |  5 +++++
  gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C | 12 ++++++++++++
  2 files changed, 17 insertions(+)
  create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C

diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 75d8c6badd66..3b8b9ed9d77b 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C
new file mode 100644
index 000000000000..f6f4cbfde122
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic4.C
@@ -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" } }

Reply via email to