When appearing in a SAVE_EXPR, it means that underneath
is a call to a constructor.
- When appearing in a CONSTRUCTOR, the expression is a
+ When appearing in a CONSTRUCTOR, the expression is an unconverted
compound literal.
When appearing in a FIELD_DECL, it means that this field
(TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
/* True if NODE is a compound-literal, i.e., a brace-enclosed
- initializer cast to a particular type. */
+ initializer cast to a particular type. This is mostly only set during
+ template parsing; once the initializer has been digested into an actual
+ value of the type, the expression is represented by a TARGET_EXPR. */
#define COMPOUND_LITERAL_P(NODE) \
(TREE_CODE (NODE) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (NODE))
return error_mark_node;
/* This is no longer a compound literal. */
- TREE_HAS_CONSTRUCTOR (expr) = 0;
+ gcc_assert (!TREE_HAS_CONSTRUCTOR (expr));
tree name = mangle_template_parm_object (expr);
tree decl = get_global_binding (name);
}
/* Represent other compound literals with TARGET_EXPR so we produce
- an lvalue, but can elide copies. */
+ a prvalue, and can elide copies. */
if (!VECTOR_TYPE_P (type))
- compound_literal = get_target_expr_sfinae (compound_literal, complain);
+ {
+ /* The CONSTRUCTOR is now an initializer, not a compound literal. */
+ TREE_HAS_CONSTRUCTOR (compound_literal) = false;
+ compound_literal = get_target_expr_sfinae (compound_literal, complain);
+ }
return compound_literal;
}
return null_member_pointer_value_p (t);
if (TREE_CODE (t) == CONSTRUCTOR)
{
- if (CONSTRUCTOR_IS_DEPENDENT (t)
+ if (COMPOUND_LITERAL_P (t)
|| BRACE_ENCLOSED_INITIALIZER_P (t))
- /* Undigested, conversions might change the zeroness.
-
- Other COMPOUND_LITERAL_P in template context are also undigested,
- but there isn't currently a way to distinguish between them and
- COMPOUND_LITERAL_P from non-template context that are digested. */
+ /* Undigested, conversions might change the zeroness. */
return false;
for (constructor_elt &elt : CONSTRUCTOR_ELTS (t))
{
/* Handle aggregate NSDMI in non-constant initializers, too. */
value = replace_placeholders (value, decl);
+ /* A COMPOUND_LITERAL_P CONSTRUCTOR is the syntactic form; by the time we get
+ here it should have been digested into an actual value for the type. */
+ gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
+ || processing_template_decl
+ || !TREE_HAS_CONSTRUCTOR (value));
+
/* If the initializer is not a constant, fill in DECL_INITIAL with
the bits that are constant, and then return an expression that
will perform the dynamic initialization. */