]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/reflection: comment on TARGET_EXPR stripping
authorMarek Polacek <polacek@redhat.com>
Tue, 20 Jan 2026 17:34:17 +0000 (12:34 -0500)
committerMarek Polacek <polacek@redhat.com>
Tue, 20 Jan 2026 18:27:47 +0000 (13:27 -0500)
As per <https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705305.html>.

gcc/cp/ChangeLog:

* reflect.cc (get_range_elts): Add comment for TARGET_EXPR stripping.
(get_vector_of_info_elts): Likewise.

gcc/cp/reflect.cc

index c1073c59a99c2c84e0788b496b2995156ea06ccc..eae70f86eac9296a722c6f442dd179f0c5c25692 100644 (file)
@@ -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<constructor_elt, va_gc> *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;