re PR c++/48535 ([C++0x][SFINAE] Hard errors during list-value-initialization)
authorJason Merrill <jason@redhat.com>
Mon, 11 Apr 2011 22:00:42 +0000 (18:00 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 11 Apr 2011 22:00:42 +0000 (18:00 -0400)
PR c++/48535
* semantics.c (finish_compound_literal): Take complain parm.
(build_lambda_object): Adjust.
* cp-tree.h: Adjust.
* call.c (convert_like_real): Adjust.
* decl.c (check_initializer): Adjust.
* parser.c (cp_parser_postfix_expression): Adjust.
(cp_parser_functional_cast): Adjust.
* pt.c (tsubst_copy_and_build): Adjust.
* typeck2.c (process_init_constructor_record): Adjust.

From-SVN: r172285

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/typeck2.c

index 69aa17081eec3ed0502ef68bd2618ccc756642cd..6732794f4be2da70a10293848038cc5236e20748 100644 (file)
@@ -1,5 +1,16 @@
 2011-04-11  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48535
+       * semantics.c (finish_compound_literal): Take complain parm.
+       (build_lambda_object): Adjust.
+       * cp-tree.h: Adjust.
+       * call.c (convert_like_real): Adjust.
+       * decl.c (check_initializer): Adjust.
+       * parser.c (cp_parser_postfix_expression): Adjust.
+       (cp_parser_functional_cast): Adjust.
+       * pt.c (tsubst_copy_and_build): Adjust.
+       * typeck2.c (process_init_constructor_record): Adjust.
+
        PR c++/48534
        * cvt.c (ocp_convert): Use build_nop to convert to underlying type
        of scoped enum.
index 4d03646b44421f9b270742e0039e44a2d4f7680e..78104b1540b768192ce1173afdb614f3d3010792 100644 (file)
@@ -5495,7 +5495,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
        elttype = cp_build_qualified_type
          (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST);
        array = build_array_of_n_type (elttype, len);
-       array = finish_compound_literal (array, new_ctor);
+       array = finish_compound_literal (array, new_ctor, complain);
 
        /* Build up the initializer_list object.  */
        totype = complete_type (totype);
index 885b31cd61ae568690b3471860e43f7b9bacb1f7..44a20ead20a2fb2e8b784a74cf32809c24926427 100644 (file)
@@ -5297,7 +5297,7 @@ extern tree finish_increment_expr         (tree, enum tree_code);
 extern tree finish_this_expr                   (void);
 extern tree finish_pseudo_destructor_expr       (tree, tree, tree);
 extern tree finish_unary_op_expr               (enum tree_code, tree);
-extern tree finish_compound_literal            (tree, tree);
+extern tree finish_compound_literal            (tree, tree, tsubst_flags_t);
 extern tree finish_fname                       (tree);
 extern void finish_translation_unit            (void);
 extern tree finish_template_type_parm          (tree, tree);
index 55ae173a02dd0906a3c91bdc3c9f3f86f8e56403..a541402ab6642f87ad2e2a183a9caae279cfdcc2 100644 (file)
@@ -5397,7 +5397,8 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
                 init appropriately so we can pass it into store_init_value
                 for the error.  */
              if (init && BRACE_ENCLOSED_INITIALIZER_P (init))
-               init = finish_compound_literal (type, init);
+               init = finish_compound_literal (type, init,
+                                               tf_warning_or_error);
              else if (CLASS_TYPE_P (type)
                       && (!init || TREE_CODE (init) == TREE_LIST))
                {
index 607e9b8f3285784b5960fe36b5f2ad0cd602db69..8414ab86481625dc2a8140b1722d78be0b83f3f0 100644 (file)
@@ -4897,7 +4897,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
                postfix_expression
                  = (finish_compound_literal
                     (type, build_constructor (init_list_type_node,
-                                              initializer_list)));
+                                              initializer_list),
+                     tf_warning_or_error));
                break;
              }
          }
@@ -19936,7 +19937,8 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
       CONSTRUCTOR_IS_DIRECT_INIT (expression_list) = 1;
       if (TREE_CODE (type) == TYPE_DECL)
        type = TREE_TYPE (type);
-      return finish_compound_literal (type, expression_list);
+      return finish_compound_literal (type, expression_list,
+                                     tf_warning_or_error);
     }
 
 
index 86274e99731b20505289b34ea8f9414763d329da..208ff2ba433c047ab7d66b81ff0a695f0070ec75 100644 (file)
@@ -13262,7 +13262,7 @@ tsubst_copy_and_build (tree t,
        CONSTRUCTOR_IS_DIRECT_INIT (r) = CONSTRUCTOR_IS_DIRECT_INIT (t);
 
        if (TREE_HAS_CONSTRUCTOR (t))
-         return finish_compound_literal (type, r);
+         return finish_compound_literal (type, r, complain);
 
        TREE_TYPE (r) = type;
        return r;
index 0b4d1ec497a8da7b90b5fd45744510dfe50713e6..e08ddb32d39618a664f460d7f9a32abf888f4d02 100644 (file)
@@ -2309,14 +2309,16 @@ finish_unary_op_expr (enum tree_code code, tree expr)
    the CONSTRUCTOR in COMPOUND_LITERAL is being cast.  */
 
 tree
-finish_compound_literal (tree type, tree compound_literal)
+finish_compound_literal (tree type, tree compound_literal,
+                        tsubst_flags_t complain)
 {
   if (type == error_mark_node)
     return error_mark_node;
 
   if (!TYPE_OBJ_P (type))
     {
-      error ("compound literal of non-object type %qT", type);
+      if (complain & tf_error)
+       error ("compound literal of non-object type %qT", type);
       return error_mark_node;
     }
 
@@ -2338,7 +2340,7 @@ finish_compound_literal (tree type, tree compound_literal)
         that it came from T{} rather than T({}).  */
       CONSTRUCTOR_IS_DIRECT_INIT (compound_literal) = 1;
       compound_literal = build_tree_list (NULL_TREE, compound_literal);
-      return build_functional_cast (type, compound_literal, tf_error);
+      return build_functional_cast (type, compound_literal, complain);
     }
 
   if (TREE_CODE (type) == ARRAY_TYPE
@@ -7928,7 +7930,7 @@ build_lambda_object (tree lambda_expr)
      But we briefly treat it as an aggregate to make this simpler.  */
   type = TREE_TYPE (lambda_expr);
   CLASSTYPE_NON_AGGREGATE (type) = 0;
-  expr = finish_compound_literal (type, expr);
+  expr = finish_compound_literal (type, expr, tf_warning_or_error);
   CLASSTYPE_NON_AGGREGATE (type) = 1;
 
  out:
index f67073bb5c87cfcf099b139c1bcbb684ab71309e..20b47d59b7e75726e4802dfa634f2584fcffb1aa 100644 (file)
@@ -1126,7 +1126,8 @@ process_init_constructor_record (tree type, tree init)
          next = build_constructor (init_list_type_node, NULL);
          if (MAYBE_CLASS_TYPE_P (TREE_TYPE (field)))
            {
-             next = finish_compound_literal (TREE_TYPE (field), next);
+             next = finish_compound_literal (TREE_TYPE (field), next,
+                                             tf_warning_or_error);
              /* direct-initialize the target. No temporary is going
                  to be involved.  */
              if (TREE_CODE (next) == TARGET_EXPR)