PR c++/68782 gcc/ * tree.c (recompute_constructor_flags): Split out from build_constructor. (verify_constructor_flags): New. * tree.h: Declare them. gcc/cp/ * constexpr.c (cxx_eval_bare_aggregate): Update TREE_CONSTANT and TREE_SIDE_EFFECTS. (cxx_eval_constant_expression) [CONSTRUCTOR]: Call verify_constructor_flags. From-SVN: r232847
28 lines
565 B
C
28 lines
565 B
C
// PR c++/68782
|
|
// { dg-do compile { target c++11 } }
|
|
|
|
#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
|
|
|
|
struct holder { int& value; };
|
|
|
|
constexpr holder from_value(int& value)
|
|
{ return { value }; }
|
|
|
|
struct aggr { int i; };
|
|
|
|
constexpr holder from_aggr(aggr& a)
|
|
{ return from_value(a.i); }
|
|
|
|
int main()
|
|
{
|
|
aggr a { 42 };
|
|
|
|
// these don't fire
|
|
assert( &from_value(a.i).value != nullptr );
|
|
assert( &a.i == &from_value(a.i).value );
|
|
|
|
// those do
|
|
assert( &from_aggr(a).value != nullptr );
|
|
assert( &a.i == &from_aggr(a).value );
|
|
}
|