2011-04-07 Jason Merrill <jason@redhat.com>
+ PR c++/48450
+ * tree.c (build_cplus_new, build_aggr_init_expr): Take complain.
+ (bot_manip): Adjust.
+ * cp-tree.h: Adjust.
+ * call.c (convert_like_real, build_cxx_call): Adjust.
+ (perform_direct_initialization_if_possible): Adjust.
+ * cvt.c (ocp_convert): Adjust.
+ * init.c (build_value_init): Adjust.
+ * semantics.c (maybe_add_lambda_conv_op): Adjust.
+ * typeck.c (unary_complex_lvalue, cp_build_modify_expr): Adjust.
+ * typeck2.c (build_functional_cast): Adjust.
+
* init.c (build_value_init_noctor): Handle REFERENCE_TYPE at top
level.
(perform_member_init): Not here.
we need to build up a TARGET_EXPR. */
if (DECL_CONSTRUCTOR_P (convfn))
{
- expr = build_cplus_new (totype, expr);
+ expr = build_cplus_new (totype, expr, complain);
/* Remember that this was list-initialization. */
if (convs->check_narrowing)
else if (diag_kind == DK_ERROR)
return error_mark_node;
}
- return build_cplus_new (totype, expr);
+ return build_cplus_new (totype, expr, complain);
case ck_ref_bind:
{
return error_mark_node;
if (MAYBE_CLASS_TYPE_P (TREE_TYPE (fn)))
- fn = build_cplus_new (TREE_TYPE (fn), fn);
+ fn = build_cplus_new (TREE_TYPE (fn), fn, tf_warning_or_error);
return convert_from_reference (fn);
}
expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
&args, type, LOOKUP_NORMAL, complain);
release_tree_vector (args);
- return build_cplus_new (type, expr);
+ return build_cplus_new (type, expr, complain);
}
/* Get the high-water mark for the CONVERSION_OBSTACK. */
extern tree build_min_nt (enum tree_code, ...);
extern tree build_min_non_dep (enum tree_code, tree, ...);
extern tree build_min_non_dep_call_vec (tree, tree, VEC(tree,gc) *);
-extern tree build_cplus_new (tree, tree);
-extern tree build_aggr_init_expr (tree, tree);
+extern tree build_cplus_new (tree, tree, tsubst_flags_t);
+extern tree build_aggr_init_expr (tree, tree, tsubst_flags_t);
extern tree get_target_expr (tree);
extern tree build_cplus_array_type (tree, tree);
extern tree build_array_of_n_type (tree, int);
release_tree_vector (ctor_vec);
}
if (ctor)
- return build_cplus_new (type, ctor);
+ return build_cplus_new (type, ctor, tf_warning_or_error);
}
if (flags & LOOKUP_COMPLAIN)
(type,
build_special_member_call (NULL_TREE, complete_ctor_identifier,
NULL, type, LOOKUP_NORMAL,
- complain));
+ complain),
+ complain);
else if (TREE_CODE (type) != UNION_TYPE && TYPE_NEEDS_CONSTRUCTING (type))
{
/* This is a class that needs constructing, but doesn't have
NULL, type, LOOKUP_NORMAL, complain);
if (ctor != error_mark_node)
{
- ctor = build_aggr_init_expr (type, ctor);
+ ctor = build_aggr_init_expr (type, ctor, complain);
AGGR_INIT_ZERO_FIRST (ctor) = 1;
}
return ctor;
VEC_address (tree, argvec));
CALL_FROM_THUNK_P (call) = 1;
if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call)))
- call = build_cplus_new (TREE_TYPE (call), call);
+ call = build_cplus_new (TREE_TYPE (call), call, tf_warning_or_error);
call = convert_from_reference (call);
finish_return_stmt (call);
callable. */
tree
-build_aggr_init_expr (tree type, tree init)
+build_aggr_init_expr (tree type, tree init, tsubst_flags_t complain)
{
tree fn;
tree slot;
/* Make sure that we're not trying to create an instance of an
abstract class. */
- abstract_virtuals_error (NULL_TREE, type);
+ if (abstract_virtuals_error_sfinae (NULL_TREE, type, complain)
+ && !(complain & tf_error))
+ return error_mark_node;
if (TREE_CODE (init) == CALL_EXPR)
fn = CALL_EXPR_FN (init);
and language-specific expression expanders. */
tree
-build_cplus_new (tree type, tree init)
+build_cplus_new (tree type, tree init, tsubst_flags_t complain)
{
- tree rval = build_aggr_init_expr (type, init);
+ tree rval = build_aggr_init_expr (type, init, complain);
tree slot;
if (TREE_CODE (rval) == AGGR_INIT_EXPR)
tree u;
if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
- u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1));
+ u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1),
+ tf_warning_or_error);
else
u = build_target_expr_with_type (TREE_OPERAND (t, 1), TREE_TYPE (t));
if (TREE_CODE (arg) == SAVE_EXPR)
targ = arg;
else
- targ = build_cplus_new (TREE_TYPE (arg), arg);
+ targ = build_cplus_new (TREE_TYPE (arg), arg, tf_warning_or_error);
return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), targ);
}
{
if (TREE_CODE (newrhs) == CALL_EXPR
&& TYPE_NEEDS_CONSTRUCTING (lhstype))
- newrhs = build_cplus_new (lhstype, newrhs);
+ newrhs = build_cplus_new (lhstype, newrhs, complain);
/* Can't initialize directly from a TARGET_EXPR, since that would
cause the lhs to be constructed twice, and possibly result in
if (exp == error_mark_node)
return error_mark_node;
- return build_cplus_new (type, exp);
+ return build_cplus_new (type, exp, complain);
}
\f