On Tue, Dec 16, 2025 at 10:48:40PM +0700, Jason Merrill wrote:
> > + tree r = finish_compound_literal (type, ctor, tf_warning_or_error,
> > + fcl_functional);
> > + if (TREE_CODE (r) == TARGET_EXPR)
>
> Let's check SIMPLE_TARGET_EXPR_P in places we're going to strip the
> TARGET_EXPR.
diff --git a/gcc/cp/reflect.cc b/gcc/cp/reflect.cc
index 4b2eeb2075f..7d472afd21a 100644
--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -593,7 +593,7 @@ 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);
- if (TREE_CODE (r) == TARGET_EXPR)
+ if (SIMPLE_TARGET_EXPR_P (r))
r = TARGET_EXPR_INITIAL (r);
return r;
}
@@ -3001,7 +3001,7 @@ 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);
- if (TREE_CODE (r) == TARGET_EXPR)
+ if (SIMPLE_TARGET_EXPR_P (r))
r = TARGET_EXPR_INITIAL (r);
return r;
}
seems to break pretty much everything unfortunately (151 FAILs compared for
make check-g++ RUNTESTFLAGS=dg.exp=reflect/* to 0 before that), e.g.
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/alignment_of1.C:72:16:
error: non-constant condition for static assertion
/home/jakub/src/gcc-reflect/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/allocator.h:212:30:
error: deallocation of already deallocated storage
or
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/annotations4.C:12:17:
error: annotation does not have structural type
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/annotations4.C:4:52:
note: 'E::e' is not public
or
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/complete1.C:42:58:
error: 'std::vector<std::meta::info>{std::_Vector_base<std::meta::info,
std::allocator<std::meta::info> >()}' is not a constant expression
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/complete1.C:42:58:
error: 'std::meta::annotations_of_with_type(^^g, ^^S<49>)' is not a constant
expression because it refers to an incompletely initialized variable
/home/jakub/src/gcc-reflect/gcc/testsuite/g++.dg/reflect/complete1.C:44:21:
error: call to consteval function 'std::meta::members_of(^^S<50>, ctx)' is not
a constant expression
Jakub