On 1/29/26 6:40 AM, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
OK.
-- >8 --
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:
Absolutely, I mean anything other than REFLECT_EXPR or error_mark_node
should be an error.
I'm not giving another error for error_mark_node since we've already
complained (but make sure we have).
gcc/cp/ChangeLog:
* reflect.cc (class_members_of): Adjust comment.
(splice): Give an error if the expression doesn't evaluate to
a REFLECT_EXPR_P.
---
gcc/cp/reflect.cc | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index bdeec2f0f38..bdac2780e65 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -6563,7 +6563,7 @@ class_members_of (location_t loc, const constexpr_ctx
*ctx, tree r,
{
tree m = field;
if (TREE_CODE (field) == FIELD_DECL && DECL_ARTIFICIAL (field))
- continue; /* Ignore bases. */
+ continue; /* Ignore bases and the vptr. */
else if (DECL_SELF_REFERENCE_P (field))
continue;
else if (TREE_CODE (field) == TYPE_DECL)
@@ -7991,9 +7991,17 @@ splice (tree refl)
refl = fold_non_dependent_expr (refl, tf_warning_or_error, true);
else
refl = cxx_constant_value (refl);
+ if (refl == error_mark_node)
+ {
+ gcc_checking_assert (seen_error ());
+ return error_mark_node;
+ }
if (!REFLECT_EXPR_P (refl))
- /* I don't wanna do your dirty work no more. */
- return error_mark_node;
+ {
+ error_at (cp_expr_loc_or_input_loc (refl), "splice argument must be an "
+ "expression of type %qs", "std::meta::info");
+ return error_mark_node;
+ }
/* We are bringing some entity from the unevaluated expressions world
to possibly outside of that, mark it used. */
base-commit: a1adc5aa30caae043cbd45dbbf9a738bebba34cc