aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-04-07 17:47:24 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-04-07 17:47:24 -0400
commit362115a9125a17809f4b7c9c37afccc9029ed733 (patch)
tree5171555c7e129348caefab585cca1c46559af02a
parent351ccf209e1e4495534044e3cd77ee03f32bdda2 (diff)
downloadgcc-362115a9125a17809f4b7c9c37afccc9029ed733.zip
gcc-362115a9125a17809f4b7c9c37afccc9029ed733.tar.gz
gcc-362115a9125a17809f4b7c9c37afccc9029ed733.tar.bz2
re PR c++/48450 ([C++0x][SFINAE] Hard errors with static_cast expressions)
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. From-SVN: r172143
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/call.c8
-rw-r--r--gcc/cp/cp-tree.h4
-rw-r--r--gcc/cp/cvt.c2
-rw-r--r--gcc/cp/init.c5
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/cp/tree.c13
-rw-r--r--gcc/cp/typeck.c4
-rw-r--r--gcc/cp/typeck2.c2
9 files changed, 34 insertions, 18 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ca7a790..b8b87cf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,17 @@
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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ad2de43..c273027 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5414,7 +5414,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
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)
@@ -5559,7 +5559,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
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:
{
@@ -6476,7 +6476,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray)
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);
}
@@ -8119,7 +8119,7 @@ perform_direct_initialization_if_possible (tree type,
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. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 94bd3ce..ea251a8 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5395,8 +5395,8 @@ extern tree build_min (enum tree_code, tree, ...);
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);
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 290b926..6551de6 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -819,7 +819,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
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)
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 005f8d6..3131690 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -342,7 +342,8 @@ build_value_init (tree type, tsubst_flags_t 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
@@ -354,7 +355,7 @@ build_value_init (tree type, tsubst_flags_t complain)
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;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5cbba33..30175af 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8429,7 +8429,7 @@ maybe_add_lambda_conv_op (tree type)
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);
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 070ba81..c2aa389 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -373,7 +373,7 @@ build_aggr_init_array (tree return_type, tree fn, tree slot, int nargs,
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;
@@ -382,7 +382,9 @@ build_aggr_init_expr (tree type, tree init)
/* 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);
@@ -437,9 +439,9 @@ build_aggr_init_expr (tree type, tree 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)
@@ -1805,7 +1807,8 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
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));
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a45ed2d..71cfd8c 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5320,7 +5320,7 @@ unary_complex_lvalue (enum tree_code code, tree arg)
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);
}
@@ -6742,7 +6742,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
{
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
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index f3a0079..f67073b 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1614,7 +1614,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
if (exp == error_mark_node)
return error_mark_node;
- return build_cplus_new (type, exp);
+ return build_cplus_new (type, exp, complain);
}