+2014-05-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * cp-tree.h (DIRECT_LIST_INIT_P): Add.
+ * call.c (convert_like_real, build_new_method_call_1): Use it.
+ * decl2.c (grokfield): Likewise.
+ * init.c (perform_member_init, build_aggr_init, expand_default_init,
+ build_new_1): Likewise.
+ * mangle.c (write_expression): Likewise.
+ * parser.c (cp_parser_late_parse_one_default_arg): Likewise.
+
2014-05-14 Jason Merrill <jason@redhat.com>
PR c++/20332
constructors, but actually trying to call one is an error. */
if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
/* Unless this is for direct-list-initialization. */
- && !(BRACE_ENCLOSED_INITIALIZER_P (expr)
- && CONSTRUCTOR_IS_DIRECT_INIT (expr)))
+ && !DIRECT_LIST_INIT_P (expr))
{
if (!(complain & tf_error))
return error_mark_node;
/* If CONSTRUCTOR_IS_DIRECT_INIT is set, this was a T{ } form
initializer, not T({ }). */
if (DECL_CONSTRUCTOR_P (fn) && args != NULL && !vec_safe_is_empty (*args)
- && BRACE_ENCLOSED_INITIALIZER_P ((**args)[0])
- && CONSTRUCTOR_IS_DIRECT_INIT ((**args)[0]))
+ && DIRECT_LIST_INIT_P ((**args)[0]))
{
tree init_list = (**args)[0];
tree init = NULL_TREE;
B b{1,2}, not B b({1,2}) or B b = {1,2}. */
#define CONSTRUCTOR_IS_DIRECT_INIT(NODE) (TREE_LANG_FLAG_0 (CONSTRUCTOR_CHECK (NODE)))
+#define DIRECT_LIST_INIT_P(NODE) \
+ (BRACE_ENCLOSED_INITIALIZER_P (NODE) && CONSTRUCTOR_IS_DIRECT_INIT (NODE))
+
/* True if NODE represents a conversion for direct-initialization in a
template. Set by perform_implicit_conversion_flags. */
#define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \
if (attrlist)
cplus_decl_attributes (&value, attrlist, 0);
- if (init && BRACE_ENCLOSED_INITIALIZER_P (init)
- && CONSTRUCTOR_IS_DIRECT_INIT (init))
+ if (init && DIRECT_LIST_INIT_P (init))
flags = LOOKUP_NORMAL;
else
flags = LOOKUP_IMPLICIT;
&& TREE_TYPE (init) == type)
/* { } mem-initializer. */
|| (TREE_CODE (init) == TREE_LIST
- && TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR
- && CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init))))
+ && DIRECT_LIST_INIT_P (TREE_VALUE (init))))
&& (CP_AGGREGATE_TYPE_P (type)
|| is_std_init_list (type)))))
{
&& TREE_CODE (init) != TREE_LIST
&& !(TREE_CODE (init) == TARGET_EXPR
&& TARGET_EXPR_DIRECT_INIT_P (init))
- && !(BRACE_ENCLOSED_INITIALIZER_P (init)
- && CONSTRUCTOR_IS_DIRECT_INIT (init)))
+ && !DIRECT_LIST_INIT_P (init))
flags |= LOOKUP_ONLYCONVERTING;
if (TREE_CODE (type) == ARRAY_TYPE)
/* If we have direct-initialization from an initializer list, pull
it out of the TREE_LIST so the code below can see it. */
if (init && TREE_CODE (init) == TREE_LIST
- && BRACE_ENCLOSED_INITIALIZER_P (TREE_VALUE (init))
- && CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init)))
+ && DIRECT_LIST_INIT_P (TREE_VALUE (init)))
{
gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0
&& TREE_CHAIN (init) == NULL_TREE);
{
tree vecinit = NULL_TREE;
if (vec_safe_length (*init) == 1
- && BRACE_ENCLOSED_INITIALIZER_P ((**init)[0])
- && CONSTRUCTOR_IS_DIRECT_INIT ((**init)[0]))
+ && DIRECT_LIST_INIT_P ((**init)[0]))
{
vecinit = (**init)[0];
if (CONSTRUCTOR_NELTS (vecinit) == 0)
write_type (type);
if (init && TREE_CODE (init) == TREE_LIST
- && TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR
- && CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init)))
+ && DIRECT_LIST_INIT_P (TREE_VALUE (init)))
write_expression (TREE_VALUE (init));
else
{
else
{
int flags = LOOKUP_IMPLICIT;
- if (BRACE_ENCLOSED_INITIALIZER_P (parsed_arg)
- && CONSTRUCTOR_IS_DIRECT_INIT (parsed_arg))
+ if (DIRECT_LIST_INIT_P (parsed_arg))
flags = LOOKUP_NORMAL;
parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags);
if (TREE_CODE (parsed_arg) == TARGET_EXPR)