]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/reflection: add fixed test [PR123871]
authorMarek Polacek <polacek@redhat.com>
Thu, 29 Jan 2026 14:39:12 +0000 (09:39 -0500)
committerMarek Polacek <polacek@redhat.com>
Thu, 29 Jan 2026 14:48:48 +0000 (09:48 -0500)
Incredibly, a patch that I just pushed (r16-7140-g101f2970adc0a7) fixed
this ICE.

I notice that we don't emit the diag_array_subscript diagnostic because
slice calls fold_non_dependent_expr which calls _eval_outermost with
allow_non_constant=true.  I wonder if we want to change this.

PR c++/123871

gcc/testsuite/ChangeLog:

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

gcc/testsuite/g++.dg/reflect/error11.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/reflect/error11.C b/gcc/testsuite/g++.dg/reflect/error11.C
new file mode 100644 (file)
index 0000000..d6c94fb
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/123871
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+#include <meta>
+
+template<class T>
+consteval auto
+test ()
+{
+  auto lambda = [](this auto){
+      constexpr std::meta::info array[1] = {^^T};
+      using X = [: array[100] :];  // { dg-error "splice argument must be" }
+      sizeof(X);
+  };
+}
+
+void
+g ()
+{
+  test<int>();
+}