Hi,

I believe that, as a general rule, a function taking a tsubst_flags_t complain parameter should propagate it, thus, in particular, call the *_sfinae variant of various helper functions we have got. The below fixes a few places where we weren't doing that (+ a couple of minor unrelated tweaks noticed while going through the code).

Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////
2012-10-07  Paolo Carlini  <paolo.carl...@oracle.com>

        * pt.c (fold_non_dependent_expr_sfinae): Remove static specifier.
        (tsubst_copy_and_build): Use get_target_expr_sfinae.
        * call.c (build_conditional_expr_1, convert_like_real): Likewise.
        * cvt.c (build_up_reference): Likewise.
        (ocp_convert): Use abstract_virtuals_error_sfinae.
        (build_up_reference): Propagate complain to cp_build_addr_expr.
        * decl.c (compute_array_index_type): Use fold_non_dependent_expr_sfinae.
        * cp-tree.h: Update declarations.

        * cvt.c (build_expr_type_conversion): Tidy.

        * tree.c (stabilize_aggr_init): Change to static.
Index: pt.c
===================================================================
--- pt.c        (revision 192179)
+++ pt.c        (working copy)
@@ -5020,7 +5020,7 @@ redeclare_class_template (tree type, tree parms)
 /* Simplify EXPR if it is a non-dependent expression.  Returns the
    (possibly simplified) expression.  */
 
-static tree
+tree
 fold_non_dependent_expr_sfinae (tree expr, tsubst_flags_t complain)
 {
   if (expr == NULL_TREE)
@@ -14287,7 +14287,8 @@ tsubst_copy_and_build (tree t,
          FIXME stop folding in cp_parser_initializer_clause.  */
       gcc_assert (TREE_CONSTANT (t));
       {
-       tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
+       tree r = get_target_expr_sfinae (RECUR (TARGET_EXPR_INITIAL (t)),
+                                        complain);
        TREE_CONSTANT (r) = true;
        RETURN (r);
       }
Index: cvt.c
===================================================================
--- cvt.c       (revision 192179)
+++ cvt.c       (working copy)
@@ -339,12 +339,12 @@ build_up_reference (tree type, tree arg, int flags
                      LOOKUP_ONLYCONVERTING|DIRECT_BIND);
     }
   else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg))
-    return get_target_expr (arg);
+    return get_target_expr_sfinae (arg, complain);
 
   /* If we had a way to wrap this up, and say, if we ever needed its
      address, transform all occurrences of the register, into a memory
      reference we could win better.  */
-  rval = cp_build_addr_expr (arg, tf_warning_or_error);
+  rval = cp_build_addr_expr (arg, complain);
   if (rval == error_mark_node)
     return error_mark_node;
 
@@ -842,7 +842,7 @@ ocp_convert (tree type, tree expr, int convtype, i
 
       ctor = e;
 
-      if (abstract_virtuals_error (NULL_TREE, type))
+      if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain))
        return error_mark_node;
 
       if (BRACE_ENCLOSED_INITIALIZER_P (ctor))
@@ -1514,8 +1514,6 @@ build_expr_type_conversion (int desires, tree expr
                  "converting NULL to non-pointer type");
     }
 
-  basetype = TREE_TYPE (expr);
-
   if (basetype == error_mark_node)
     return error_mark_node;
 
Index: tree.c
===================================================================
--- tree.c      (revision 192179)
+++ tree.c      (working copy)
@@ -3557,7 +3557,7 @@ stabilize_call (tree call, tree *initp)
    arguments, while, upon return, *INITP contains an expression to
    compute the arguments.  */
 
-void
+static void
 stabilize_aggr_init (tree call, tree *initp)
 {
   tree inits = NULL_TREE;
Index: call.c
===================================================================
--- call.c      (revision 192179)
+++ call.c      (working copy)
@@ -4777,7 +4777,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tr
         but now we sometimes wrap them in NOP_EXPRs so the test would
         fail.  */
       if (CLASS_TYPE_P (TREE_TYPE (result)))
-       result = get_target_expr (result);
+       result = get_target_expr_sfinae (result, complain);
       /* If this expression is an rvalue, but might be mistaken for an
         lvalue, we must add a NON_LVALUE_EXPR.  */
       result = rvalue (result);
@@ -5883,7 +5883,7 @@ convert_like_real (conversion *convs, tree expr, t
        field = next_initializable_field (DECL_CHAIN (field));
        CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len));
        new_ctor = build_constructor (totype, vec);
-       return get_target_expr (new_ctor);
+       return get_target_expr_sfinae (new_ctor, complain);
       }
 
     case ck_aggr:
@@ -5899,7 +5899,8 @@ convert_like_real (conversion *convs, tree expr, t
          return fold_if_not_in_template (expr);
        }
       expr = reshape_init (totype, expr, complain);
-      return get_target_expr (digest_init (totype, expr, complain));
+      return get_target_expr_sfinae (digest_init (totype, expr, complain),
+                                    complain);
 
     default:
       break;
Index: cp-tree.h
===================================================================
--- cp-tree.h   (revision 192179)
+++ cp-tree.h   (working copy)
@@ -5411,6 +5411,7 @@ extern tree build_non_dependent_expr              (tree);
 extern void make_args_non_dependent            (VEC(tree,gc) *);
 extern bool reregister_specialization          (tree, tree, tree);
 extern tree fold_non_dependent_expr            (tree);
+extern tree fold_non_dependent_expr_sfinae     (tree, tsubst_flags_t);
 extern bool alias_type_or_template_p            (tree);
 extern bool alias_template_specialization_p     (tree);
 extern bool explicit_class_specialization_p     (tree);
@@ -5700,7 +5701,6 @@ extern void lang_check_failed                     (const 
char *, int
                                                 const char *) 
ATTRIBUTE_NORETURN;
 extern tree stabilize_expr                     (tree, tree *);
 extern void stabilize_call                     (tree, tree *);
-extern void stabilize_aggr_init                        (tree, tree *);
 extern bool stabilize_init                     (tree, tree *);
 extern tree add_stmt_to_compound               (tree, tree);
 extern void init_tree                          (void);
Index: decl.c
===================================================================
--- decl.c      (revision 192179)
+++ decl.c      (working copy)
@@ -7990,7 +7990,7 @@ compute_array_index_type (tree name, tree size, ts
           NOP_EXPR with TREE_SIDE_EFFECTS; don't fold in that case.  */;
       else
        {
-         size = fold_non_dependent_expr (size);
+         size = fold_non_dependent_expr_sfinae (size, complain);
 
          if (CLASS_TYPE_P (type)
              && CLASSTYPE_LITERAL_P (type))

Reply via email to