Commit 014397c2 by Paolo Carlini Committed by Paolo Carlini

cp-tree.h (DIRECT_LIST_INIT_P): Add.

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.

From-SVN: r210438
parent d40aeed8
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> 2014-05-14 Jason Merrill <jason@redhat.com>
PR c++/20332 PR c++/20332
......
...@@ -6119,8 +6119,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -6119,8 +6119,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
constructors, but actually trying to call one is an error. */ constructors, but actually trying to call one is an error. */
if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn) if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
/* Unless this is for direct-list-initialization. */ /* Unless this is for direct-list-initialization. */
&& !(BRACE_ENCLOSED_INITIALIZER_P (expr) && !DIRECT_LIST_INIT_P (expr))
&& CONSTRUCTOR_IS_DIRECT_INIT (expr)))
{ {
if (!(complain & tf_error)) if (!(complain & tf_error))
return error_mark_node; return error_mark_node;
...@@ -7859,8 +7858,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, ...@@ -7859,8 +7858,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
/* If CONSTRUCTOR_IS_DIRECT_INIT is set, this was a T{ } form /* If CONSTRUCTOR_IS_DIRECT_INIT is set, this was a T{ } form
initializer, not T({ }). */ initializer, not T({ }). */
if (DECL_CONSTRUCTOR_P (fn) && args != NULL && !vec_safe_is_empty (*args) if (DECL_CONSTRUCTOR_P (fn) && args != NULL && !vec_safe_is_empty (*args)
&& BRACE_ENCLOSED_INITIALIZER_P ((**args)[0]) && DIRECT_LIST_INIT_P ((**args)[0]))
&& CONSTRUCTOR_IS_DIRECT_INIT ((**args)[0]))
{ {
tree init_list = (**args)[0]; tree init_list = (**args)[0];
tree init = NULL_TREE; tree init = NULL_TREE;
......
...@@ -3437,6 +3437,9 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) ...@@ -3437,6 +3437,9 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
B b{1,2}, not B b({1,2}) or B b = {1,2}. */ 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 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 /* True if NODE represents a conversion for direct-initialization in a
template. Set by perform_implicit_conversion_flags. */ template. Set by perform_implicit_conversion_flags. */
#define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \ #define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \
......
...@@ -983,8 +983,7 @@ grokfield (const cp_declarator *declarator, ...@@ -983,8 +983,7 @@ grokfield (const cp_declarator *declarator,
if (attrlist) if (attrlist)
cplus_decl_attributes (&value, attrlist, 0); cplus_decl_attributes (&value, attrlist, 0);
if (init && BRACE_ENCLOSED_INITIALIZER_P (init) if (init && DIRECT_LIST_INIT_P (init))
&& CONSTRUCTOR_IS_DIRECT_INIT (init))
flags = LOOKUP_NORMAL; flags = LOOKUP_NORMAL;
else else
flags = LOOKUP_IMPLICIT; flags = LOOKUP_IMPLICIT;
......
...@@ -642,8 +642,7 @@ perform_member_init (tree member, tree init) ...@@ -642,8 +642,7 @@ perform_member_init (tree member, tree init)
&& TREE_TYPE (init) == type) && TREE_TYPE (init) == type)
/* { } mem-initializer. */ /* { } mem-initializer. */
|| (TREE_CODE (init) == TREE_LIST || (TREE_CODE (init) == TREE_LIST
&& TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR && DIRECT_LIST_INIT_P (TREE_VALUE (init))))
&& CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init))))
&& (CP_AGGREGATE_TYPE_P (type) && (CP_AGGREGATE_TYPE_P (type)
|| is_std_init_list (type))))) || is_std_init_list (type)))))
{ {
...@@ -1515,8 +1514,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) ...@@ -1515,8 +1514,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
&& TREE_CODE (init) != TREE_LIST && TREE_CODE (init) != TREE_LIST
&& !(TREE_CODE (init) == TARGET_EXPR && !(TREE_CODE (init) == TARGET_EXPR
&& TARGET_EXPR_DIRECT_INIT_P (init)) && TARGET_EXPR_DIRECT_INIT_P (init))
&& !(BRACE_ENCLOSED_INITIALIZER_P (init) && !DIRECT_LIST_INIT_P (init))
&& CONSTRUCTOR_IS_DIRECT_INIT (init)))
flags |= LOOKUP_ONLYCONVERTING; flags |= LOOKUP_ONLYCONVERTING;
if (TREE_CODE (type) == ARRAY_TYPE) if (TREE_CODE (type) == ARRAY_TYPE)
...@@ -1589,8 +1587,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, ...@@ -1589,8 +1587,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
/* If we have direct-initialization from an initializer list, pull /* If we have direct-initialization from an initializer list, pull
it out of the TREE_LIST so the code below can see it. */ it out of the TREE_LIST so the code below can see it. */
if (init && TREE_CODE (init) == TREE_LIST if (init && TREE_CODE (init) == TREE_LIST
&& BRACE_ENCLOSED_INITIALIZER_P (TREE_VALUE (init)) && DIRECT_LIST_INIT_P (TREE_VALUE (init)))
&& CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init)))
{ {
gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0 gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0
&& TREE_CHAIN (init) == NULL_TREE); && TREE_CHAIN (init) == NULL_TREE);
...@@ -2791,8 +2788,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, ...@@ -2791,8 +2788,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
{ {
tree vecinit = NULL_TREE; tree vecinit = NULL_TREE;
if (vec_safe_length (*init) == 1 if (vec_safe_length (*init) == 1
&& BRACE_ENCLOSED_INITIALIZER_P ((**init)[0]) && DIRECT_LIST_INIT_P ((**init)[0]))
&& CONSTRUCTOR_IS_DIRECT_INIT ((**init)[0]))
{ {
vecinit = (**init)[0]; vecinit = (**init)[0];
if (CONSTRUCTOR_NELTS (vecinit) == 0) if (CONSTRUCTOR_NELTS (vecinit) == 0)
......
...@@ -2806,8 +2806,7 @@ write_expression (tree expr) ...@@ -2806,8 +2806,7 @@ write_expression (tree expr)
write_type (type); write_type (type);
if (init && TREE_CODE (init) == TREE_LIST if (init && TREE_CODE (init) == TREE_LIST
&& TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR && DIRECT_LIST_INIT_P (TREE_VALUE (init)))
&& CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init)))
write_expression (TREE_VALUE (init)); write_expression (TREE_VALUE (init));
else else
{ {
......
...@@ -23674,8 +23674,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl, ...@@ -23674,8 +23674,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,
else else
{ {
int flags = LOOKUP_IMPLICIT; int flags = LOOKUP_IMPLICIT;
if (BRACE_ENCLOSED_INITIALIZER_P (parsed_arg) if (DIRECT_LIST_INIT_P (parsed_arg))
&& CONSTRUCTOR_IS_DIRECT_INIT (parsed_arg))
flags = LOOKUP_NORMAL; flags = LOOKUP_NORMAL;
parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags); parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags);
if (TREE_CODE (parsed_arg) == TARGET_EXPR) if (TREE_CODE (parsed_arg) == TARGET_EXPR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment