diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-02 19:14:23 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-02 19:14:23 +0000 |
commit | c28ddc97adc500ba5c4bbb6994d7cb8327445dcb (patch) | |
tree | 8becd43c0137d4c13ec1df45fe08c64cceb0a023 /gcc/cp/call.c | |
parent | 78b7a67520737f2e029383dd5a89ba8c1c4a3ef9 (diff) | |
download | gcc-c28ddc97adc500ba5c4bbb6994d7cb8327445dcb.tar.gz |
PR c++/53524
gcc/cp/
* call.c (build_conditional_expr_1): Don't warn about comparison of
two enumerators before their enumeration is complete.
(build_new_op_1): Call decay_conversion before warn_logical_operator.
* decl.c (build_enumerator): Set DECL_CONTEXT of an enumerator to
its enumeration.
* decl2.c (mark_used): Call used_types_insert for enums.
* semantics.c (finish_id_expression): Don't decay CONST_DECL.
(finish_member_declaration): Don't change DECL_CONTEXT of enumerators.
* class.c (check_field_decls): Don't change DECL_CONTEXT of enums.
* typeck.c (convert_for_assignment): Don't decay CONST_DECL.
(build_class_member_access_expr): Look through unscoped enums.
* search.c (context_for_name_lookup): Look through unscoped enums.
* pt.c (tsubst_copy_and_build): Don't decay CONST_DECL.
(tsubst_copy): Use DECL_CONTEXT to find the enumeration.
* tree.c (decl_linkage): Likewise.
* cvt.c (ocp_convert): Check decayed expr for enum range warning.
gcc/c-family/
* c-common.c (get_priority): Call default_conversion.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189174 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 09965b321cc..72394f4af60 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4365,6 +4365,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, struct z_candidate *candidates = 0; struct z_candidate *cand; void *p; + tree orig_arg2, orig_arg3; /* As a G++ extension, the second argument to the conditional can be omitted. (So that `a ? : c' is roughly equivalent to `a ? a : @@ -4404,6 +4405,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, array-to-pointer (_conv.array_), and function-to-pointer (_conv.func_) standard conversions are performed on the second and third operands. */ + orig_arg2 = arg2; + orig_arg3 = arg3; arg2_type = unlowered_expr_type (arg2); arg3_type = unlowered_expr_type (arg3); if (VOID_TYPE_P (arg2_type) || VOID_TYPE_P (arg3_type)) @@ -4701,7 +4704,12 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3, if (TREE_CODE (arg2_type) == ENUMERAL_TYPE && TREE_CODE (arg3_type) == ENUMERAL_TYPE) { - if (complain & tf_warning) + if (TREE_CODE (orig_arg2) == CONST_DECL + && TREE_CODE (orig_arg3) == CONST_DECL + && DECL_CONTEXT (orig_arg2) == DECL_CONTEXT (orig_arg3)) + /* Two enumerators from the same enumeration can have different + types when the enumeration is still being defined. */; + else if (complain & tf_warning) warning (OPT_Wenum_compare, "enumeral mismatch in conditional expression: %qT vs %qT", arg2_type, arg3_type); @@ -5221,16 +5229,20 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, if (arg2) { + conv = cand->convs[1]; + if (conv->kind == ck_ref_bind) + conv = next_conversion (conv); + else + arg2 = decay_conversion (arg2, complain); + /* We need to call warn_logical_operator before - converting arg2 to a boolean_type. */ + converting arg2 to a boolean_type, but after + decaying an enumerator to its value. */ if (complain & tf_warning) warn_logical_operator (loc, code, boolean_type_node, code_orig_arg1, arg1, code_orig_arg2, arg2); - conv = cand->convs[1]; - if (conv->kind == ck_ref_bind) - conv = next_conversion (conv); arg2 = convert_like (conv, arg2, complain); } if (arg3) |