From 72b3e203352b9cc6524531e8a0975c672dfdca2e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 8 Jul 2016 17:32:18 -0400 Subject: [PATCH] Use lvalue_p instead of real_lvalue_p. * cp-tree.h: Unpoison lvalue_p. * call.c, class.c, constexpr.c, cvt.c, init.c, lambda.c, pt.c, tree.c, typeck.c, typeck2.c: Use lvalue_p instead of real_lvalue_p. From-SVN: r238183 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 26 +++++++++++++------------- gcc/cp/class.c | 2 +- gcc/cp/constexpr.c | 2 +- gcc/cp/cp-tree.h | 4 ---- gcc/cp/cvt.c | 6 +++--- gcc/cp/init.c | 2 +- gcc/cp/lambda.c | 2 +- gcc/cp/pt.c | 4 ++-- gcc/cp/tree.c | 16 +++++++--------- gcc/cp/typeck.c | 10 +++++----- gcc/cp/typeck2.c | 2 +- 12 files changed, 40 insertions(+), 41 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8d8535d7921..e70e102c6e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-07-08 Jason Merrill + * cp-tree.h: Unpoison lvalue_p. + * call.c, class.c, constexpr.c, cvt.c, init.c, lambda.c, pt.c, + tree.c, typeck.c, typeck2.c: Use lvalue_p instead of + real_lvalue_p. + * tree.c (obvalue_p): Rename from lvalue_p. (lvalue_p): Define for c-common. * call.c, cp-tree.h, cvt.c, init.c: Adjust. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c90b8af115f..9b028144aaa 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2925,7 +2925,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, if (code == COND_EXPR) { - if (real_lvalue_p (args[i])) + if (lvalue_p (args[i])) vec_safe_push (types[i], build_reference_type (argtypes[i])); vec_safe_push (types[i], TYPE_MAIN_VARIANT (argtypes[i])); @@ -2962,7 +2962,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, } else { - if (code == COND_EXPR && real_lvalue_p (args[i])) + if (code == COND_EXPR && lvalue_p (args[i])) vec_safe_push (types[i], build_reference_type (argtypes[i])); type = non_reference (argtypes[i]); if (i != 0 || ! ref1) @@ -4554,7 +4554,7 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain) the constraint that the reference must bind directly. */ if (glvalue_p (e2)) { - tree rtype = cp_build_reference_type (t2, !real_lvalue_p (e2)); + tree rtype = cp_build_reference_type (t2, !lvalue_p (e2)); conv = implicit_conversion (rtype, t1, e1, @@ -4619,7 +4619,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, tree arg3_type; tree result = NULL_TREE; tree result_type = NULL_TREE; - bool lvalue_p = true; + bool is_lvalue = true; struct z_candidate *candidates = 0; struct z_candidate *cand; void *p; @@ -4636,7 +4636,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, "ISO C++ forbids omitting the middle term of a ?: expression"); /* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */ - if (real_lvalue_p (arg1)) + if (lvalue_p (arg1)) arg2 = arg1 = cp_stabilize_reference (arg1); else arg2 = arg1 = save_expr (arg1); @@ -4871,7 +4871,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, return error_mark_node; } - lvalue_p = false; + is_lvalue = false; goto valid_operands; } /* [expr.cond] @@ -4886,7 +4886,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, || (same_type_ignoring_top_level_qualifiers_p (arg2_type, arg3_type) && glvalue_p (arg2) && glvalue_p (arg3) - && real_lvalue_p (arg2) == real_lvalue_p (arg3)))) + && lvalue_p (arg2) == lvalue_p (arg3)))) { conversion *conv2; conversion *conv3; @@ -4984,7 +4984,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, If the second and third operands are glvalues of the same value category and have the same type, the result is of that type and value category. */ - if (((real_lvalue_p (arg2) && real_lvalue_p (arg3)) + if (((lvalue_p (arg2) && lvalue_p (arg3)) || (xvalue_p (arg2) && xvalue_p (arg3))) && same_type_p (arg2_type, arg3_type)) { @@ -5001,7 +5001,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, cv-qualified) class type, overload resolution is used to determine the conversions (if any) to be applied to the operands (_over.match.oper_, _over.built_). */ - lvalue_p = false; + is_lvalue = false; if (!same_type_p (arg2_type, arg3_type) && (CLASS_TYPE_P (arg2_type) || CLASS_TYPE_P (arg3_type))) { @@ -5187,7 +5187,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, /* We can't use result_type below, as fold might have returned a throw_expr. */ - if (!lvalue_p) + if (!is_lvalue) { /* Expand both sides into the same slot, hopefully the target of the ?: expression. We used to check for TARGET_EXPRs here, @@ -6694,10 +6694,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, { tree extype = TREE_TYPE (expr); if (TYPE_REF_IS_RVALUE (ref_type) - && real_lvalue_p (expr)) + && lvalue_p (expr)) error_at (loc, "cannot bind %qT lvalue to %qT", extype, totype); - else if (!TYPE_REF_IS_RVALUE (ref_type) && !real_lvalue_p (expr) + else if (!TYPE_REF_IS_RVALUE (ref_type) && !lvalue_p (expr) && !CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (ref_type))) error_at (loc, "invalid initialization of non-const reference of " "type %qT from an rvalue of type %qT", totype, extype); @@ -10042,7 +10042,7 @@ initialize_reference (tree type, tree expr, convert_like (conv, expr, complain); else if (!CP_TYPE_CONST_P (TREE_TYPE (type)) && !TYPE_REF_IS_RVALUE (type) - && !real_lvalue_p (expr)) + && !lvalue_p (expr)) error_at (loc, "invalid initialization of non-const reference of " "type %qT from an rvalue of type %qT", type, TREE_TYPE (expr)); diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 31fa4b03136..b2db7f8aab8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -347,7 +347,7 @@ build_base_path (enum tree_code code, if (!want_pointer) { - rvalue = !real_lvalue_p (expr); + rvalue = !lvalue_p (expr); /* This must happen before the call to save_expr. */ expr = cp_build_addr_expr (expr, complain); } diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index ba40435ef67..b9834a7e734 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2620,7 +2620,7 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init, (atype, TREE_TYPE (init))); eltinit = cp_build_array_ref (input_location, init, idx, tf_warning_or_error); - if (!real_lvalue_p (init)) + if (!lvalue_p (init)) eltinit = move (eltinit); eltinit = force_rvalue (eltinit, tf_warning_or_error); eltinit = (cxx_eval_constant_expression diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a3e53a9c109..74b8c7c7963 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6516,10 +6516,6 @@ extern int member_p (const_tree); extern cp_lvalue_kind real_lvalue_p (const_tree); extern cp_lvalue_kind lvalue_kind (const_tree); extern bool glvalue_p (const_tree); -/* obvalue_p used to be named lvalue_p, but that didn't match the C++ - definition of lvalue. For now, let's not use the name lvalue_p in the front - end; later we can rename real_lvalue_p to lvalue_p. */ -#define lvalue_p(T) syntax error, use real_lvalue_p extern bool obvalue_p (const_tree); extern bool xvalue_p (const_tree); extern tree cp_stabilize_reference (tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 9dd383e0681..85b3047d9f1 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -317,7 +317,7 @@ build_up_reference (tree type, tree arg, int flags, tree decl, gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); - if ((flags & DIRECT_BIND) && ! real_lvalue_p (arg)) + if ((flags & DIRECT_BIND) && ! lvalue_p (arg)) { /* Create a new temporary variable. We can't just use a TARGET_EXPR here because it needs to live as long as DECL. */ @@ -439,7 +439,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, = build_type_conversion (reftype, expr); if (rval_as_conversion && rval_as_conversion != error_mark_node - && real_lvalue_p (rval_as_conversion)) + && lvalue_p (rval_as_conversion)) { expr = rval_as_conversion; rval_as_conversion = NULL_TREE; @@ -457,7 +457,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, tree ttr = lvalue_type (expr); if ((complain & tf_error) - && ! real_lvalue_p (expr)) + && ! lvalue_p (expr)) diagnose_ref_binding (loc, reftype, intype, decl); if (! (convtype & CONV_CONST) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 69ff61d72ad..b4a4388d705 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3750,7 +3750,7 @@ static bool vec_copy_assign_is_trivial (tree inner_elt_type, tree init) { tree fromtype = inner_elt_type; - if (real_lvalue_p (init)) + if (lvalue_p (init)) fromtype = cp_build_reference_type (fromtype, /*rval*/false); return is_trivially_xible (MODIFY_EXPR, inner_elt_type, fromtype); } diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 3822882acca..4d6d80fe128 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -489,7 +489,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, if (by_reference_p) { type = build_reference_type (type); - if (!dependent_type_p (type) && !real_lvalue_p (initializer)) + if (!dependent_type_p (type) && !lvalue_p (initializer)) error ("cannot capture %qE by reference", initializer); } else diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c5f65a7f677..a1b0ca9a858 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6533,7 +6533,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; } - if (!real_lvalue_p (expr)) + if (!lvalue_p (expr)) { if (complain & tf_error) error ("%qE is not a valid template argument for type %qT " @@ -18046,7 +18046,7 @@ maybe_adjust_types_for_deduction (unification_kind_t strict, && TYPE_REF_IS_RVALUE (*parm) && TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM && cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED - && (arg_expr ? real_lvalue_p (arg_expr) + && (arg_expr ? lvalue_p (arg_expr) /* try_one_overload doesn't provide an arg_expr, but functions are always lvalues. */ : TREE_CODE (*arg) == FUNCTION_TYPE)) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9fda74db2da..4cbf6215a13 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -252,9 +252,7 @@ lvalue_kind (const_tree ref) return op1_lvalue_kind; } -/* Returns the kind of lvalue that REF is, in the sense of - [basic.lval]. This function should really be named lvalue_p; it - computes the C++ definition of lvalue. */ +/* Returns the kind of lvalue that REF is, in the sense of [basic.lval]. */ cp_lvalue_kind real_lvalue_p (const_tree ref) @@ -266,15 +264,15 @@ real_lvalue_p (const_tree ref) return kind; } -/* Defined for c-common; the front end should use real_lvalue_p. */ +/* c-common wants us to return bool. */ bool -(lvalue_p) (const_tree t) +lvalue_p (const_tree t) { return real_lvalue_p (t); } -/* This differs from real_lvalue_p in that xvalues are included. */ +/* This differs from lvalue_p in that xvalues are included. */ bool glvalue_p (const_tree ref) @@ -615,7 +613,7 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) { tree init_type = strip_array_types (TREE_TYPE (init)); tree dummy = build_dummy_object (init_type); - if (!real_lvalue_p (init)) + if (!lvalue_p (init)) dummy = move (dummy); argvec->quick_push (dummy); } @@ -3331,7 +3329,7 @@ error_type (tree arg) ; else if (TREE_CODE (type) == ERROR_MARK) ; - else if (real_lvalue_p (arg)) + else if (lvalue_p (arg)) type = build_reference_type (lvalue_type (arg)); else if (MAYBE_CLASS_TYPE_P (type)) type = lvalue_type (arg); @@ -4278,7 +4276,7 @@ stabilize_expr (tree exp, tree* initp) } else { - bool xval = !real_lvalue_p (exp); + bool xval = !lvalue_p (exp); exp = cp_build_addr_expr (exp, tf_warning_or_error); init_expr = get_target_expr (exp); exp = TARGET_EXPR_SLOT (init_expr); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a0e6c519a96..2f2beead74c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6296,7 +6296,7 @@ build_x_conditional_expr (location_t loc, tree ifexp, tree op1, tree op2, /* Remember that the result is an lvalue or xvalue. */ if (glvalue_p (expr) && !glvalue_p (min)) TREE_TYPE (min) = cp_build_reference_type (TREE_TYPE (min), - !real_lvalue_p (expr)); + !lvalue_p (expr)); expr = convert_from_reference (min); } return expr; @@ -6535,7 +6535,7 @@ maybe_warn_about_useless_cast (tree type, tree expr, tsubst_flags_t complain) { if ((TREE_CODE (type) == REFERENCE_TYPE && (TYPE_REF_IS_RVALUE (type) - ? xvalue_p (expr) : real_lvalue_p (expr)) + ? xvalue_p (expr) : lvalue_p (expr)) && same_type_p (TREE_TYPE (expr), TREE_TYPE (type))) || same_type_p (TREE_TYPE (expr), type)) warning (OPT_Wuseless_cast, "useless cast to type %qT", type); @@ -6637,7 +6637,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, if (TREE_CODE (type) == REFERENCE_TYPE && CLASS_TYPE_P (TREE_TYPE (type)) && CLASS_TYPE_P (intype) - && (TYPE_REF_IS_RVALUE (type) || real_lvalue_p (expr)) + && (TYPE_REF_IS_RVALUE (type) || lvalue_p (expr)) && DERIVED_FROM_P (intype, TREE_TYPE (type)) && can_convert (build_pointer_type (TYPE_MAIN_VARIANT (intype)), build_pointer_type (TYPE_MAIN_VARIANT @@ -6984,7 +6984,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, reinterpret_cast. */ if (TREE_CODE (type) == REFERENCE_TYPE) { - if (! real_lvalue_p (expr)) + if (! lvalue_p (expr)) { if (complain & tf_error) error ("invalid cast of an rvalue expression of type " @@ -7231,7 +7231,7 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, { reference_type = dst_type; if (!TYPE_REF_IS_RVALUE (dst_type) - ? real_lvalue_p (expr) + ? lvalue_p (expr) : obvalue_p (expr)) /* OK. */; else diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 65d91c97784..b1206c09a0e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1895,7 +1895,7 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) operand is a pointer to member function with ref-qualifier &&. */ if (FUNCTION_REF_QUALIFIED (type)) { - bool lval = real_lvalue_p (datum); + bool lval = lvalue_p (datum); if (lval && FUNCTION_RVALUE_QUALIFIED (type)) { if (complain & tf_error) -- 2.30.2