On 5/26/26 12:06 PM, Marek Polacek wrote:
On Tue, May 26, 2026 at 05:56:21PM +0200, Jakub Jelinek wrote:
On Tue, May 26, 2026 at 09:38:33AM -0400, Marek Polacek wrote:
I'm not against this but I would think we may want to check error_operand_p (h)
in process_metafunction instead?
That works too in reflect/* testing.
Thanks, LGTM.
OK.
2026-05-26 Jakub Jelinek <[email protected]>
PR c++/125412
* reflect.cc (process_metafunction): If ht is error_operand_p, set
*non_constant_p and return NULL_TREE.
* g++.dg/reflect/pr125412.C: New test.
--- gcc/cp/reflect.cc.jj 2026-05-25 10:42:52.681817335 +0200
+++ gcc/cp/reflect.cc 2026-05-26 17:29:29.483733178 +0200
@@ -7887,6 +7887,11 @@ process_metafunction (const constexpr_ct
if (*jump_target || *non_constant_p)
return NULL_TREE;
ht = REFLECT_EXPR_HANDLE (info);
+ if (error_operand_p (ht))
+ {
+ *non_constant_p = true;
+ return NULL_TREE;
+ }
if (METAFN_KIND_ARG (minfo, argno) == METAFN_KIND_ARG_TINFO
&& eval_is_type (ht) != boolean_true_node)
return throw_exception_nontype (loc, ctx, fun, non_constant_p,
--- gcc/testsuite/g++.dg/reflect/pr125412.C.jj 2026-05-25 12:02:08.456192292
+0200
+++ gcc/testsuite/g++.dg/reflect/pr125412.C 2026-05-25 12:10:38.405976096
+0200
@@ -0,0 +1,24 @@
+// PR c++/125412
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+#include <meta>
+
+void
+foo ()
+{
+}
+
+auto bar ();
+
+template <typename T>
+auto a = foo (); // { dg-error "variable or field 'a' declared void" }
+template <typename T>
+auto b = bar (); // { dg-error "use of 'auto bar\\\(\\\)' before deduction of
'auto'" }
+
+consteval {
+ auto c = substitute (^^a, { ^^int });
+ std::meta::extract <int> (c);
+ auto d = substitute (^^b, { ^^int });
+ std::meta::extract <int> (d);
+}
Jakub
Marek