diff mbox

[C++] Add IS_DIRECT_INITIALIZER?

Message ID 5373A160.4090000@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 14, 2014, 5:01 p.m. UTC
... the draft ;)

///////////////////
diff mbox

Patch

Index: call.c
===================================================================
--- call.c	(revision 210424)
+++ call.c	(working copy)
@@ -6071,8 +6071,7 @@  convert_like_real (conversion *convs, tree expr, t
 	   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)))
+	    && !IS_DIRECT_INITIALIZER (expr))
 	  {
 	    if (!(complain & tf_error))
 	      return error_mark_node;
@@ -7803,8 +7802,7 @@  build_new_method_call_1 (tree instance, tree fns,
   /* 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]))
+      && IS_DIRECT_INITIALIZER ((**args)[0]))
     {
       tree init_list = (**args)[0];
       tree init = NULL_TREE;
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 210424)
+++ cp-tree.h	(working copy)
@@ -3437,6 +3437,9 @@  more_aggr_init_expr_args_p (const aggr_init_expr_a
    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 IS_DIRECT_INITIALIZER(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) \
Index: decl2.c
===================================================================
--- decl2.c	(revision 210424)
+++ decl2.c	(working copy)
@@ -983,8 +983,7 @@  grokfield (const cp_declarator *declarator,
   if (attrlist)
     cplus_decl_attributes (&value, attrlist, 0);
 
-  if (init && BRACE_ENCLOSED_INITIALIZER_P (init)
-      && CONSTRUCTOR_IS_DIRECT_INIT (init))
+  if (init && IS_DIRECT_INITIALIZER (init))
     flags = LOOKUP_NORMAL;
   else
     flags = LOOKUP_IMPLICIT;
Index: init.c
===================================================================
--- init.c	(revision 210424)
+++ init.c	(working copy)
@@ -642,8 +642,7 @@  perform_member_init (tree member, tree init)
 		     && TREE_TYPE (init) == type)
 		    /* { } mem-initializer.  */
 		    || (TREE_CODE (init) == TREE_LIST
-			&& TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR
-			&& CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init))))
+			&& IS_DIRECT_INITIALIZER (TREE_VALUE (init))))
 		   && (CP_AGGREGATE_TYPE_P (type)
 		       || is_std_init_list (type)))))
     {
@@ -1515,8 +1514,7 @@  build_aggr_init (tree exp, tree init, int flags, t
       && 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)))
+      && !IS_DIRECT_INITIALIZER (init))
     flags |= LOOKUP_ONLYCONVERTING;
 
   if (TREE_CODE (type) == ARRAY_TYPE)
@@ -1589,8 +1587,7 @@  expand_default_init (tree binfo, tree true_exp, tr
   /* 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)))
+      && IS_DIRECT_INITIALIZER (TREE_VALUE (init)))
     {
       gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0
 			   && TREE_CHAIN (init) == NULL_TREE);
@@ -2791,8 +2788,7 @@  build_new_1 (vec<tree, va_gc> **placement, tree ty
 	{
 	  tree vecinit = NULL_TREE;
 	  if (vec_safe_length (*init) == 1
-	      && BRACE_ENCLOSED_INITIALIZER_P ((**init)[0])
-	      && CONSTRUCTOR_IS_DIRECT_INIT ((**init)[0]))
+	      && IS_DIRECT_INITIALIZER ((**init)[0]))
 	    {
 	      vecinit = (**init)[0];
 	      if (CONSTRUCTOR_NELTS (vecinit) == 0)
Index: mangle.c
===================================================================
--- mangle.c	(revision 210424)
+++ mangle.c	(working copy)
@@ -2806,8 +2806,7 @@  write_expression (tree expr)
       write_type (type);
 
       if (init && TREE_CODE (init) == TREE_LIST
-	  && TREE_CODE (TREE_VALUE (init)) == CONSTRUCTOR
-	  && CONSTRUCTOR_IS_DIRECT_INIT (TREE_VALUE (init)))
+	  && IS_DIRECT_INITIALIZER (TREE_VALUE (init)))
 	write_expression (TREE_VALUE (init));
       else
 	{
Index: parser.c
===================================================================
--- parser.c	(revision 210424)
+++ parser.c	(working copy)
@@ -23674,8 +23674,7 @@  cp_parser_late_parse_one_default_arg (cp_parser *p
       else
 	{
 	  int flags = LOOKUP_IMPLICIT;
-	  if (BRACE_ENCLOSED_INITIALIZER_P (parsed_arg)
-	      && CONSTRUCTOR_IS_DIRECT_INIT (parsed_arg))
+	  if (IS_DIRECT_INITIALIZER (parsed_arg))
 	    flags = LOOKUP_NORMAL;
 	  parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags);
 	  if (TREE_CODE (parsed_arg) == TARGET_EXPR)