diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 30 | ||||
-rw-r--r-- | gcc/cp/init.c | 23 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 105 |
9 files changed, 135 insertions, 63 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ebab140..4b5105e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,30 @@ +2008-09-23 Aldy Hernandez <aldyh@redhat.com> + + * typeck.c (build_array_ref): Pass location to cp_build_binary_op. + (get_member_function_from_ptrfunc): Same. + (build_x_binary_op): Same. + (build_binary_op): Same. + (cp_build_binary_op): New location argument. + (pointer_diff): Pass location to cp_build_binary_op. + (cp_truthvalue_conversion): Pass location to build_binary_op. + (convert_ptrmem): Pass location to cp_build_binary_op. + (cp_build_modify_expr): Same. + (build_ptrmemfunc): Same. + * init.c (expand_cleanup_for_base): Pass location to + c_common_truthvalue_conversion. + (build_new_1): Pass location to cp_build_binary_op. + (build_vec_delete_1): Pass location to *build_binary_op, + c_common_truthvalue_conversion. + (build_vec_init): Same. + (build_delete): Same. + * decl.c (compute_array_index_type): Same. + * call.c (build_new_op): Same. + * rtti.c (build_dynamic_cast_1): Same. + * cp-tree.h: Add argument to cp_build_binary_op. + * semantics.c (handle_omp_for_class_iterator): Pass location to + *build_binary_op, c_common_truthvalue_conversion. + * decl2.c (get_guard_cond): Same. + 2008-09-17 Richard Guenther <rguenther@suse.de> PR c++/22374 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 653e06e..bdaf7fd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4199,7 +4199,7 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3, case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: - return cp_build_binary_op (code, arg1, arg2, complain); + return cp_build_binary_op (input_location, code, arg1, arg2, complain); case UNARY_PLUS_EXPR: case NEGATE_EXPR: diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 065e47d..c32fff6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4963,7 +4963,8 @@ extern tree composite_pointer_type (tree, tree, tree, tree, const char*, tsubst_flags_t); extern tree merge_types (tree, tree); extern tree check_return_expr (tree, bool *); -extern tree cp_build_binary_op (enum tree_code, tree, tree, +extern tree cp_build_binary_op (location_t, + enum tree_code, tree, tree, tsubst_flags_t); #define cxx_sizeof(T) cxx_sizeof_or_alignof_type (T, SIZEOF_EXPR, true) extern tree build_ptrmemfunc_access_expr (tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f57ca87..82e0bba 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7223,7 +7223,8 @@ compute_array_index_type (tree name, tree size) cp_build_binary_op will be appropriately folded. */ saved_processing_template_decl = processing_template_decl; processing_template_decl = 0; - itype = cp_build_binary_op (MINUS_EXPR, + itype = cp_build_binary_op (input_location, + MINUS_EXPR, cp_convert (ssizetype, size), cp_convert (ssizetype, integer_one_node), tf_warning_or_error); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 5aecf3c..b326752 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2530,14 +2530,16 @@ get_guard_cond (tree guard) guard_value = integer_one_node; if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard))) guard_value = convert (TREE_TYPE (guard), guard_value); - guard = cp_build_binary_op (BIT_AND_EXPR, guard, guard_value, + guard = cp_build_binary_op (input_location, + BIT_AND_EXPR, guard, guard_value, tf_warning_or_error); } guard_value = integer_zero_node; if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard))) guard_value = convert (TREE_TYPE (guard), guard_value); - return cp_build_binary_op (EQ_EXPR, guard, guard_value, + return cp_build_binary_op (input_location, + EQ_EXPR, guard, guard_value, tf_warning_or_error); } @@ -2927,20 +2929,22 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp) last to destroy the variable. */ else if (initp) guard_cond - = cp_build_binary_op (EQ_EXPR, + = cp_build_binary_op (input_location, + EQ_EXPR, cp_build_unary_op (PREINCREMENT_EXPR, - guard, - /*noconvert=*/1, - tf_warning_or_error), + guard, + /*noconvert=*/1, + tf_warning_or_error), integer_one_node, tf_warning_or_error); else guard_cond - = cp_build_binary_op (EQ_EXPR, + = cp_build_binary_op (input_location, + EQ_EXPR, cp_build_unary_op (PREDECREMENT_EXPR, - guard, - /*noconvert=*/1, - tf_warning_or_error), + guard, + /*noconvert=*/1, + tf_warning_or_error), integer_zero_node, tf_warning_or_error); @@ -2993,7 +2997,8 @@ do_static_initialization_or_destruction (tree vars, bool initp) /* Build the outer if-stmt to check for initialization or destruction. */ init_if_stmt = begin_if_stmt (); cond = initp ? integer_one_node : integer_zero_node; - cond = cp_build_binary_op (EQ_EXPR, + cond = cp_build_binary_op (input_location, + EQ_EXPR, initialize_p_decl, cond, tf_warning_or_error); @@ -3026,7 +3031,8 @@ do_static_initialization_or_destruction (tree vars, bool initp) /* Conditionalize this initialization on being in the right priority and being initializing/finalizing appropriately. */ priority_if_stmt = begin_if_stmt (); - cond = cp_build_binary_op (EQ_EXPR, + cond = cp_build_binary_op (input_location, + EQ_EXPR, priority_decl, build_int_cst (NULL_TREE, priority), tf_warning_or_error); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1c722f5..d68dd2d 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1001,7 +1001,7 @@ expand_cleanup_for_base (tree binfo, tree flag) tf_warning_or_error); if (flag) expr = fold_build3 (COND_EXPR, void_type_node, - c_common_truthvalue_conversion (flag), + c_common_truthvalue_conversion (input_location, flag), expr, integer_zero_node); finish_eh_cleanup (expr); @@ -1877,7 +1877,8 @@ build_new_1 (tree placement, tree type, tree nelts, tree init, for (elt_type = type; TREE_CODE (elt_type) == ARRAY_TYPE; elt_type = TREE_TYPE (elt_type)) - nelts = cp_build_binary_op (MULT_EXPR, nelts, + nelts = cp_build_binary_op (input_location, + MULT_EXPR, nelts, array_type_nelts_top (elt_type), complain); @@ -2177,7 +2178,8 @@ build_new_1 (tree placement, tree type, tree nelts, tree init, } init_expr = build_vec_init (init_expr, - cp_build_binary_op (MINUS_EXPR, outer_nelts, + cp_build_binary_op (input_location, + MINUS_EXPR, outer_nelts, integer_one_node, complain), init, @@ -2312,7 +2314,8 @@ build_new_1 (tree placement, tree type, tree nelts, tree init, { if (check_new) { - tree ifexp = cp_build_binary_op (NE_EXPR, alloc_node, + tree ifexp = cp_build_binary_op (input_location, + NE_EXPR, alloc_node, integer_zero_node, complain); rval = build_conditional_expr (ifexp, rval, alloc_node, @@ -2579,7 +2582,8 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, cookie_size = targetm.cxx.get_cookie_size (type); base_tbd = cp_convert (ptype, - cp_build_binary_op (MINUS_EXPR, + cp_build_binary_op (input_location, + MINUS_EXPR, cp_convert (string_type_node, base), cookie_size, @@ -2933,13 +2937,15 @@ build_vec_init (tree base, tree maxindex, tree init, && from_array != 2) { tree e; - tree m = cp_build_binary_op (MINUS_EXPR, maxindex, iterator, + tree m = cp_build_binary_op (input_location, + MINUS_EXPR, maxindex, iterator, complain); /* Flatten multi-dimensional array since build_vec_delete only expects one-dimensional array. */ if (TREE_CODE (type) == ARRAY_TYPE) - m = cp_build_binary_op (MULT_EXPR, m, + m = cp_build_binary_op (input_location, + MULT_EXPR, m, array_type_nelts_total (type), complain); @@ -3167,7 +3173,8 @@ build_delete (tree type, tree addr, special_function_kind auto_delete, ifexp = integer_one_node; else /* Handle deleting a null pointer. */ - ifexp = fold (cp_build_binary_op (NE_EXPR, addr, integer_zero_node, + ifexp = fold (cp_build_binary_op (input_location, + NE_EXPR, addr, integer_zero_node, tf_warning_or_error)); if (ifexp != integer_one_node) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 1c67832..1d5da67 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -721,7 +721,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) tree neq; result = save_expr (result); - neq = c_common_truthvalue_conversion (result); + neq = c_common_truthvalue_conversion (input_location, result); return cp_convert (type, build3 (COND_EXPR, TREE_TYPE (result), neq, result, bad)); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c6f921a..82a0495 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4107,7 +4107,8 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, tf_warning_or_error)); *pre_body = pop_stmt_list (*pre_body); - cond = cp_build_binary_op (TREE_CODE (cond), decl, diff, + cond = cp_build_binary_op (elocus, + TREE_CODE (cond), decl, diff, tf_warning_or_error); incr = build_modify_expr (decl, PLUS_EXPR, incr); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index cfa33ae..75bcf9c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2655,7 +2655,8 @@ build_array_ref (tree array, tree idx, location_t loc) warn_array_subscript_with_type_char (idx); - ret = cp_build_indirect_ref (cp_build_binary_op (PLUS_EXPR, ar, ind, + ret = cp_build_indirect_ref (cp_build_binary_op (input_location, + PLUS_EXPR, ar, ind, tf_warning_or_error), "array indexing", tf_warning_or_error); @@ -2718,16 +2719,20 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) switch (TARGET_PTRMEMFUNC_VBIT_LOCATION) { case ptrmemfunc_vbit_in_pfn: - e1 = cp_build_binary_op (BIT_AND_EXPR, idx, integer_one_node, + e1 = cp_build_binary_op (input_location, + BIT_AND_EXPR, idx, integer_one_node, tf_warning_or_error); - idx = cp_build_binary_op (MINUS_EXPR, idx, integer_one_node, + idx = cp_build_binary_op (input_location, + MINUS_EXPR, idx, integer_one_node, tf_warning_or_error); break; case ptrmemfunc_vbit_in_delta: - e1 = cp_build_binary_op (BIT_AND_EXPR, delta, integer_one_node, + e1 = cp_build_binary_op (input_location, + BIT_AND_EXPR, delta, integer_one_node, tf_warning_or_error); - delta = cp_build_binary_op (RSHIFT_EXPR, delta, integer_one_node, + delta = cp_build_binary_op (input_location, + RSHIFT_EXPR, delta, integer_one_node, tf_warning_or_error); break; @@ -3141,15 +3146,16 @@ build_x_binary_op (enum tree_code code, tree arg1, enum tree_code arg1_code, /* For the c-common bits. */ tree -build_binary_op (enum tree_code code, tree op0, tree op1, +build_binary_op (location_t location, enum tree_code code, tree op0, tree op1, int convert_p ATTRIBUTE_UNUSED) { - return cp_build_binary_op(code, op0, op1, tf_warning_or_error); + return cp_build_binary_op (location, code, op0, op1, tf_warning_or_error); } /* Build a binary-operation expression without default conversions. CODE is the kind of expression to build. + LOCATION is the location_t of the operator in the source code. This function differs from `build' in several ways: the data type of the result is computed and recorded in it, warnings are generated if arg data types are invalid, @@ -3167,7 +3173,8 @@ build_binary_op (enum tree_code code, tree op0, tree op1, multiple inheritance, and deal with pointer to member functions. */ tree -cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, +cp_build_binary_op (location_t location, + enum tree_code code, tree orig_op0, tree orig_op1, tsubst_flags_t complain) { tree op0, op1; @@ -3555,18 +3562,22 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, { tree pfn0 = pfn_from_ptrmemfunc (op0); tree delta0 = delta_from_ptrmemfunc (op0); - tree e1 = cp_build_binary_op (EQ_EXPR, + tree e1 = cp_build_binary_op (location, + EQ_EXPR, pfn0, fold_convert (TREE_TYPE (pfn0), integer_zero_node), complain); - tree e2 = cp_build_binary_op (BIT_AND_EXPR, + tree e2 = cp_build_binary_op (location, + BIT_AND_EXPR, delta0, integer_one_node, complain); - e2 = cp_build_binary_op (EQ_EXPR, e2, integer_zero_node, + e2 = cp_build_binary_op (location, + EQ_EXPR, e2, integer_zero_node, complain); - op0 = cp_build_binary_op (TRUTH_ANDIF_EXPR, e1, e2, + op0 = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e1, e2, complain); op1 = cp_convert (TREE_TYPE (op0), integer_one_node); } @@ -3578,7 +3589,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, result_type = TREE_TYPE (op0); } else if (TYPE_PTRMEMFUNC_P (type1) && null_ptr_cst_p (op0)) - return cp_build_binary_op (code, op1, op0, complain); + return cp_build_binary_op (location, code, op1, op0, complain); else if (TYPE_PTRMEMFUNC_P (type0) && TYPE_PTRMEMFUNC_P (type1)) { tree type; @@ -3626,28 +3637,34 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, pointer-to-member is any member with a zero PFN and LSB of the DELTA field is 0. */ - e1 = cp_build_binary_op (BIT_AND_EXPR, + e1 = cp_build_binary_op (location, BIT_AND_EXPR, delta0, integer_one_node, complain); - e1 = cp_build_binary_op (EQ_EXPR, e1, integer_zero_node, + e1 = cp_build_binary_op (location, + EQ_EXPR, e1, integer_zero_node, complain); - e2 = cp_build_binary_op (BIT_AND_EXPR, + e2 = cp_build_binary_op (location, BIT_AND_EXPR, delta1, integer_one_node, complain); - e2 = cp_build_binary_op (EQ_EXPR, e2, integer_zero_node, + e2 = cp_build_binary_op (location, + EQ_EXPR, e2, integer_zero_node, complain); - e1 = cp_build_binary_op (TRUTH_ANDIF_EXPR, e2, e1, + e1 = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e2, e1, complain); - e2 = cp_build_binary_op (EQ_EXPR, + e2 = cp_build_binary_op (location, EQ_EXPR, pfn0, fold_convert (TREE_TYPE (pfn0), integer_zero_node), complain); - e2 = cp_build_binary_op (TRUTH_ANDIF_EXPR, e2, e1, complain); - e1 = cp_build_binary_op (EQ_EXPR, delta0, delta1, complain); - e1 = cp_build_binary_op (TRUTH_ORIF_EXPR, e1, e2, complain); + e2 = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e2, e1, complain); + e1 = cp_build_binary_op (location, + EQ_EXPR, delta0, delta1, complain); + e1 = cp_build_binary_op (location, + TRUTH_ORIF_EXPR, e1, e2, complain); } else { @@ -3660,19 +3677,24 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, pointer-to-member is any member with a zero PFN; the DELTA field is unspecified. */ - e1 = cp_build_binary_op (EQ_EXPR, delta0, delta1, complain); - e2 = cp_build_binary_op (EQ_EXPR, + e1 = cp_build_binary_op (location, + EQ_EXPR, delta0, delta1, complain); + e2 = cp_build_binary_op (location, + EQ_EXPR, pfn0, fold_convert (TREE_TYPE (pfn0), integer_zero_node), complain); - e1 = cp_build_binary_op (TRUTH_ORIF_EXPR, e1, e2, complain); + e1 = cp_build_binary_op (location, + TRUTH_ORIF_EXPR, e1, e2, complain); } e2 = build2 (EQ_EXPR, boolean_type_node, pfn0, pfn1); - e = cp_build_binary_op (TRUTH_ANDIF_EXPR, e2, e1, complain); + e = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e2, e1, complain); if (code == EQ_EXPR) return e; - return cp_build_binary_op (EQ_EXPR, e, integer_zero_node, complain); + return cp_build_binary_op (location, + EQ_EXPR, e, integer_zero_node, complain); } else { @@ -3773,7 +3795,7 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, || !same_scalar_type_ignoring_signedness (TREE_TYPE (type0), TREE_TYPE (type1))) { - binary_op_error (code, type0, type1); + binary_op_error (location, code, type0, type1); return error_mark_node; } arithmetic_types_p = 1; @@ -3857,8 +3879,8 @@ cp_build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, && !processing_template_decl && (complain & tf_warning)) { - warn_for_sign_compare (orig_op0, orig_op1, op0, op1, - result_type, resultcode); + warn_for_sign_compare (location, orig_op0, orig_op1, op0, op1, + result_type, resultcode); } } @@ -3954,7 +3976,8 @@ pointer_diff (tree op0, tree op1, tree ptrtype) /* First do the subtraction as integers; then drop through to build the divide operator. */ - op0 = cp_build_binary_op (MINUS_EXPR, + op0 = cp_build_binary_op (input_location, + MINUS_EXPR, cp_convert (restype, op0), cp_convert (restype, op1), tf_warning_or_error); @@ -4073,9 +4096,10 @@ cp_truthvalue_conversion (tree expr) { tree type = TREE_TYPE (expr); if (TYPE_PTRMEM_P (type)) - return build_binary_op (NE_EXPR, expr, integer_zero_node, 1); + return build_binary_op (EXPR_LOCATION (expr), + NE_EXPR, expr, integer_zero_node, 1); else - return c_common_truthvalue_conversion (expr); + return c_common_truthvalue_conversion (input_location, expr); } /* Just like cp_truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. */ @@ -4968,12 +4992,14 @@ convert_ptrmem (tree type, tree expr, bool allow_inverse_p, { tree cond, op1, op2; - cond = cp_build_binary_op (EQ_EXPR, + cond = cp_build_binary_op (input_location, + EQ_EXPR, expr, build_int_cst (TREE_TYPE (expr), -1), tf_warning_or_error); op1 = build_nop (ptrdiff_type_node, expr); - op2 = cp_build_binary_op (PLUS_EXPR, op1, delta, + op2 = cp_build_binary_op (input_location, + PLUS_EXPR, op1, delta, tf_warning_or_error); expr = fold_build3 (COND_EXPR, ptrdiff_type_node, cond, op1, op2); @@ -5914,7 +5940,8 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, || MAYBE_CLASS_TYPE_P (lhstype))); lhs = stabilize_reference (lhs); - newrhs = cp_build_binary_op (modifycode, lhs, rhs, + newrhs = cp_build_binary_op (EXPR_LOCATION (lhs), + modifycode, lhs, rhs, complain); if (newrhs == error_mark_node) { @@ -6303,9 +6330,11 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p) gcc_assert (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (delta), ptrdiff_type_node)); if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta) - n = cp_build_binary_op (LSHIFT_EXPR, n, integer_one_node, + n = cp_build_binary_op (input_location, + LSHIFT_EXPR, n, integer_one_node, tf_warning_or_error); - delta = cp_build_binary_op (PLUS_EXPR, delta, n, tf_warning_or_error); + delta = cp_build_binary_op (input_location, + PLUS_EXPR, delta, n, tf_warning_or_error); return build_ptrmemfunc1 (to_type, delta, npfn); } |