Here we are printing:
note: but ''lang_type' not supported by dump_expr<expression error>' is a type
because we represent a null reflection with unknown_type_node. Let's
detect splicing a null reflection.
gcc/cp/ChangeLog:
* reflect.cc (splice): Detect a null reflection.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/null6.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
return error_mark_node;
}
+ if (compare_reflections (refl, get_null_reflection ()))
+ {
+ error_at (loc, "cannot splice a null reflection");
+ return error_mark_node;
+ }
+
/* This isn't checked in check_splice_expr, because reflect_kind isn't
available there and variable_of (parameters_of (...)[...]) can be
spliced. */
--- /dev/null
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+using info = decltype(^^::);
+constexpr auto null = info{};
+constexpr auto q = [:null:]; // { dg-error "cannot splice a null reflection" }
+[:null:] t1; // { dg-error "cannot splice a null reflection|expected" }
+[:null:]<int> t2; // { dg-error "cannot splice a null reflection|expected" }