The following testcase ICEs during error recovery, because we aren't
prepared to handle error_mark_node type.
Fixed thusly.
2026-05-27 Jakub Jelinek <jakub@redhat.com>
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.
Reviewed-by: Jason Merrill <jason@redhat.com>
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,
--- /dev/null
+// 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);
+}