]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Handle SPLICE_SCOPE in cp_walk_subtrees [PR123659]
authorJakub Jelinek <jakub@redhat.com>
Sat, 7 Feb 2026 10:07:28 +0000 (11:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 7 Feb 2026 10:09:20 +0000 (11:09 +0100)
SPLICE_SCOPE is a TYPE_P, but didn't have its SPLICE_SCOPE_EXPR
walked by cp_walk_tree, so the following testcase has been rejected
because it didn't find a pack in it.

SPLICE_EXPR is fine, as it is tcc_expression and walk_tree by default
walks all the tcc_exception operands for unknown trees.

2026-02-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/123659
* tree.cc (cp_walk_subtrees): Handle SPLICE_SCOPE.

* g++.dg/reflect/splice9.C: New test.

gcc/cp/tree.cc
gcc/testsuite/g++.dg/reflect/splice9.C [new file with mode: 0644]

index b8820baf203f901de318b73527a9fded04c799a9..74e387c2d41654bdbf51b88714a16df6e53769d1 100644 (file)
@@ -6273,6 +6273,11 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
       WALK_SUBTREE (TYPE_MAX_VALUE (t));
       break;
 
+    case SPLICE_SCOPE:
+      WALK_SUBTREE (SPLICE_SCOPE_EXPR (t));
+      *walk_subtrees_p = 0;
+      break;
+
     default:
       return NULL_TREE;
     }
diff --git a/gcc/testsuite/g++.dg/reflect/splice9.C b/gcc/testsuite/g++.dg/reflect/splice9.C
new file mode 100644 (file)
index 0000000..458b651
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/123659
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+#include <meta>
+
+struct S {};
+
+template <int...I>
+void
+foo ()
+{
+  static constexpr std::meta::info t[] { ^^int, ^^long, ^^S, ^^double };
+  [] (typename [: t[I] :]... a) {} (1, S {}, 2.5, 3L, 4L);
+}
+
+void
+bar ()
+{
+  foo <0, 2, 3, 1, 1> ();
+}