[PATCH] c++/reflection: add assert to eval_type_trait
Jason Merrill
jason@redhat.com
Thu Jan 29 11:03:56 GMT 2026
On 1/29/26 5:30 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>.
>
> Since we check eval_is_type in process_metafunction:
>
> if (eval_is_type (ht) != boolean_true_node)
> return throw_exception_nontype (loc, ctx, fun, non_constant_p,
> jump_target);
>
> finish_trait_expr should never return error_mark_node. We can ensure
> that it's so by adding an assert.
>
> gcc/cp/ChangeLog:
>
> * reflect.cc (eval_type_trait): Assert that finish_trait_expr didn't
> return error_mark_node.
> ---
> gcc/cp/reflect.cc | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
> index bdeec2f0f38..fa039ac6d60 100644
> --- a/gcc/cp/reflect.cc
> +++ b/gcc/cp/reflect.cc
> @@ -3919,6 +3919,7 @@ static tree
> eval_type_trait (location_t loc, tree type1, tree type2, cp_trait_kind kind)
> {
> tree r = finish_trait_expr (loc, kind, type1, type2);
> + gcc_checking_assert (r != error_mark_node);
> STRIP_ANY_LOCATION_WRAPPER (r);
> return r;
> }
>
> base-commit: b20e68022a3f49010028dc01dab570c68071e3db
More information about the Gcc-patches
mailing list