From: Marek Polacek Date: Tue, 20 Jan 2026 17:34:17 +0000 (-0500) Subject: c++/reflection: comment on TARGET_EXPR stripping X-Git-Tag: basepoints/gcc-17~1869 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=05ffa494db87bfe3acd717d8cfd3c2c7302a1dbd;p=thirdparty%2Fgcc.git c++/reflection: comment on TARGET_EXPR stripping As per . gcc/cp/ChangeLog: * reflect.cc (get_range_elts): Add comment for TARGET_EXPR stripping. (get_vector_of_info_elts): Likewise. --- diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc index c1073c59a99..eae70f86eac 100644 --- a/gcc/cp/reflect.cc +++ b/gcc/cp/reflect.cc @@ -600,6 +600,11 @@ get_range_elts (location_t loc, const constexpr_ctx *ctx, tree call, int n, TREE_STATIC (ctor) = true; tree r = finish_compound_literal (type, ctor, tf_warning_or_error, fcl_functional); + /* Here, we're evaluating an AGGR_INIT_EXPR, which is already + embedded in a TARGET_EXPR, so we don't want to add another + TARGET_EXPR inside it. Note that SIMPLE_TARGET_EXPR_P would + always be false because the TARGET_EXPR_INITIAL is an + AGGR_INIT_EXPR with void type. */ if (TREE_CODE (r) == TARGET_EXPR) r = TARGET_EXPR_INITIAL (r); return r; @@ -2983,6 +2988,11 @@ get_vector_of_info_elts (vec *elts) return error_mark_node; tree r = finish_compound_literal (type, ctor, tf_warning_or_error, fcl_functional); + /* Here, we're evaluating an AGGR_INIT_EXPR, which is already + embedded in a TARGET_EXPR, so we don't want to add another + TARGET_EXPR inside it. Note that SIMPLE_TARGET_EXPR_P would + always be false because the TARGET_EXPR_INITIAL is an + AGGR_INIT_EXPR with void type. */ if (TREE_CODE (r) == TARGET_EXPR) r = TARGET_EXPR_INITIAL (r); return r;