diff options
Diffstat (limited to 'gcc/cp/cvt.c')
-rw-r--r-- | gcc/cp/cvt.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index c7ffb16..f136d5b 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -140,7 +140,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) intype_class = TREE_TYPE (intype); type_class = TREE_TYPE (type); - same_p = same_type_p (TYPE_MAIN_VARIANT (intype_class), + same_p = same_type_p (TYPE_MAIN_VARIANT (intype_class), TYPE_MAIN_VARIANT (type_class)); binfo = NULL_TREE; /* Try derived to base conversion. */ @@ -174,7 +174,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) } else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype)) { - tree b1; + tree b1; tree b2; tree binfo; enum tree_code code = PLUS_EXPR; @@ -211,7 +211,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) expr = cplus_expand_constant (expr); if (binfo && !integer_zerop (BINFO_OFFSET (binfo))) - expr = size_binop (code, + expr = size_binop (code, build_nop (sizetype, expr), BINFO_OFFSET (binfo)); return build_nop (type, expr); @@ -255,7 +255,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) } else expr = build_int_cst (type, 0); - + return expr; } else if (TYPE_PTR_TO_MEMBER_P (type) && INTEGRAL_CODE_P (form)) @@ -274,7 +274,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) as a pointer. */ gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))) == GET_MODE_SIZE (TYPE_MODE (type))); - + return convert_to_pointer (type, expr); } @@ -295,7 +295,7 @@ convert_to_pointer_force (tree type, tree expr) { tree intype = TREE_TYPE (expr); enum tree_code form = TREE_CODE (intype); - + if (form == POINTER_TYPE) { intype = TYPE_MAIN_VARIANT (intype); @@ -363,7 +363,7 @@ build_up_reference (tree type, tree arg, int flags, tree decl) /* Process the initializer for the declaration. */ DECL_INITIAL (arg) = targ; - cp_finish_decl (arg, targ, NULL_TREE, + cp_finish_decl (arg, targ, NULL_TREE, LOOKUP_ONLYCONVERTING|DIRECT_BIND); } else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg)) @@ -398,7 +398,7 @@ build_up_reference (tree type, tree arg, int flags, tree decl) /* Subroutine of convert_to_reference. REFTYPE is the target reference type. INTYPE is the original rvalue type and DECL is an optional _DECL node for diagnostics. - + [dcl.init.ref] says that if an rvalue is used to initialize a reference, then the reference must be to a non-volatile const type. */ @@ -407,7 +407,7 @@ static void warn_ref_binding (tree reftype, tree intype, tree decl) { tree ttl = TREE_TYPE (reftype); - + if (!CP_TYPE_CONST_NON_VOLATILE_P (ttl)) { const char *msg; @@ -446,9 +446,9 @@ convert_to_reference (tree reftype, tree expr, int convtype, tree rval_as_conversion = NULL_TREE; bool can_convert_intype_to_type; - if (TREE_CODE (type) == FUNCTION_TYPE + if (TREE_CODE (type) == FUNCTION_TYPE && TREE_TYPE (expr) == unknown_type_node) - expr = instantiate_type (type, expr, + expr = instantiate_type (type, expr, (flags & LOOKUP_COMPLAIN) ? tf_error | tf_warning : tf_none); @@ -491,7 +491,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, if (! real_lvalue_p (expr)) warn_ref_binding (reftype, intype, decl); - + if (! (convtype & CONV_CONST) && !at_least_as_qualified_p (ttl, ttr)) pedwarn ("conversion from %qT to %qT discards qualifiers", @@ -514,7 +514,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, COMPARE_BASE | COMPARE_DERIVED))) warning (0, "casting %qT to %qT does not dereference pointer", intype, reftype); - + rval = build_unary_op (ADDR_EXPR, expr, 0); if (rval != error_mark_node) rval = convert_force (build_pointer_type (TREE_TYPE (reftype)), @@ -554,7 +554,7 @@ convert_from_reference (tree val) { tree t = canonical_type_variant (TREE_TYPE (TREE_TYPE (val))); tree ref = build1 (INDIRECT_REF, t, val); - + /* We *must* set TREE_READONLY when dereferencing a pointer to const, so that we get the proper error message if the result is used to assign to. Also, &* is supposed to be a no-op. */ @@ -565,7 +565,7 @@ convert_from_reference (tree val) REFERENCE_REF_P (ref) = 1; val = ref; } - + return val; } @@ -752,7 +752,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags) the target with the temp (see [dcl.init]). */ ctor = build_user_type_conversion (type, ctor, flags); else - ctor = build_special_member_call (NULL_TREE, + ctor = build_special_member_call (NULL_TREE, complete_ctor_identifier, build_tree_list (NULL_TREE, ctor), type, flags); @@ -780,13 +780,13 @@ ocp_convert (tree type, tree expr, int convtype, int flags) volatile references we do not do this interpretation, because that would make it impossible to ignore the reference return value from functions. We issue warnings in the confusing cases. - + IMPLICIT is tells us the context of an implicit void conversion. */ tree convert_to_void (tree expr, const char *implicit) { - if (expr == error_mark_node + if (expr == error_mark_node || TREE_TYPE (expr) == error_mark_node) return error_mark_node; if (!TREE_TYPE (expr)) @@ -813,12 +813,12 @@ convert_to_void (tree expr, const char *implicit) tree new_op2 = convert_to_void (op2, (implicit && !TREE_SIDE_EFFECTS (op1) ? "third operand of conditional" : NULL)); - + expr = build3 (COND_EXPR, TREE_TYPE (new_op1), TREE_OPERAND (expr, 0), new_op1, new_op2); break; } - + case COMPOUND_EXPR: { /* The second part of a compound expr contains the value. */ @@ -826,7 +826,7 @@ convert_to_void (tree expr, const char *implicit) tree new_op1 = convert_to_void (op1, (implicit && !TREE_NO_WARNING (expr) ? "right-hand operand of comma" : NULL)); - + if (new_op1 != op1) { tree t = build2 (COMPOUND_EXPR, TREE_TYPE (new_op1), @@ -836,15 +836,15 @@ convert_to_void (tree expr, const char *implicit) break; } - + case NON_LVALUE_EXPR: case NOP_EXPR: /* These have already decayed to rvalue. */ break; - + case CALL_EXPR: /* We have a special meaning for volatile void fn(). */ break; - + case INDIRECT_REF: { tree type = TREE_TYPE (expr); @@ -852,7 +852,7 @@ convert_to_void (tree expr, const char *implicit) == REFERENCE_TYPE; int is_volatile = TYPE_VOLATILE (type); int is_complete = COMPLETE_TYPE_P (complete_type (type)); - + if (is_volatile && !is_complete) warning (0, "object of incomplete type %qT will not be accessed in %s", type, implicit ? implicit : "void context"); @@ -862,16 +862,16 @@ convert_to_void (tree expr, const char *implicit) implicit ? implicit : "void context"); if (is_reference || !is_volatile || !is_complete) expr = TREE_OPERAND (expr, 0); - + break; } - + case VAR_DECL: { /* External variables might be incomplete. */ tree type = TREE_TYPE (expr); int is_complete = COMPLETE_TYPE_P (complete_type (type)); - + if (TYPE_VOLATILE (type) && !is_complete) warning (0, "object %qE of incomplete type %qT will not be accessed in %s", expr, type, implicit ? implicit : "void context"); @@ -882,7 +882,7 @@ convert_to_void (tree expr, const char *implicit) } { tree probe = expr; - + if (TREE_CODE (probe) == ADDR_EXPR) probe = TREE_OPERAND (expr, 0); if (type_unknown_p (probe)) @@ -898,7 +898,7 @@ convert_to_void (tree expr, const char *implicit) warning (0, "%s is a reference, not call, to function %qE", implicit, expr); } - + if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr))) { if (implicit && warn_unused_value && !TREE_NO_WARNING (expr)) @@ -907,12 +907,12 @@ convert_to_void (tree expr, const char *implicit) been explicitly cast to void, so we must do so here. */ if (!TREE_SIDE_EFFECTS (expr)) warning (0, "%s has no effect", implicit); - else - { + else + { tree e; enum tree_code code; enum tree_code_class class; - + e = expr; /* We might like to warn about (say) "(int) f()", as the cast has no effect, but the compiler itself will @@ -931,7 +931,7 @@ convert_to_void (tree expr, const char *implicit) class = TREE_CODE_CLASS (code); if (class == tcc_comparison || class == tcc_unary - || (class == tcc_binary + || (class == tcc_binary && !(code == MODIFY_EXPR || code == INIT_EXPR || code == PREDECREMENT_EXPR @@ -991,7 +991,7 @@ convert_force (tree type, tree expr, int convtype) enum tree_code code = TREE_CODE (type); if (code == REFERENCE_TYPE) - return (fold_if_not_in_template + return (fold_if_not_in_template (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN, NULL_TREE))); @@ -1043,11 +1043,11 @@ build_expr_type_conversion (int desires, tree expr, bool complain) tree conv = NULL_TREE; tree winner = NULL_TREE; - if (expr == null_node - && (desires & WANT_INT) + if (expr == null_node + && (desires & WANT_INT) && !(desires & WANT_NULL)) warning (0, "converting NULL to non-pointer type"); - + basetype = TREE_TYPE (expr); if (basetype == error_mark_node) @@ -1070,7 +1070,7 @@ build_expr_type_conversion (int desires, tree expr, bool complain) return (desires & WANT_FLOAT) ? expr : NULL_TREE; case POINTER_TYPE: return (desires & WANT_POINTER) ? expr : NULL_TREE; - + case FUNCTION_TYPE: case ARRAY_TYPE: return (desires & WANT_POINTER) ? decay_conversion (expr) @@ -1180,7 +1180,7 @@ type_promotes_to (tree type) } else if (type == float_type_node) type = double_type_node; - + return type; } @@ -1193,7 +1193,7 @@ type_promotes_to (tree type) to TYPE. Return the resulting expression, or error_mark_node if the conversion was impossible. */ -tree +tree perform_qualification_conversions (tree type, tree expr) { tree expr_type; |