diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2009-07-16 22:29:52 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-07-16 22:29:52 +0000 |
commit | db3927fb49c9f13a0da61a75d771f51dc7c45b92 (patch) | |
tree | e4de0ffc0a0ca77f35b03bf9e8a248a4b5735f6a /gcc/c-common.c | |
parent | c32097d8b4fb21997c571cf6520431fa7d06090f (diff) | |
download | gcc-db3927fb49c9f13a0da61a75d771f51dc7c45b92.zip gcc-db3927fb49c9f13a0da61a75d771f51dc7c45b92.tar.gz gcc-db3927fb49c9f13a0da61a75d771f51dc7c45b92.tar.bz2 |
re PR c/40435 (Revision 148442 caused many regressions on trunk)
2009-07-17 Aldy Hernandez <aldyh@redhat.com>
Manuel López-Ibáñez <manu@gcc.gnu.org>
PR 40435
* tree-complex.c, tree-loop-distribution.c,
tree.c, tree.h, builtins.c, fold-const.c, omp-low.c,
cgraphunit.c, tree-ssa-ccp.c, tree-ssa-dom.c,
gimple-low.c, expr.c, tree-ssa-ifcombine.c, c-decl.c,
stor-layout.c, tree-if-conv.c, c-typeck.c,
gimplify.c, calls.c, tree-sra.c, tree-mudflap.c,
tree-ssa-copy.c, tree-ssa-forwprop.c, c-convert.c, c-omp.c,
varasm.c, tree-inline.c, c-common.c,
c-common.h, gimple.c, tree-switch-conversion.c, gimple.h,
tree-cfg.c, c-parser.c, convert.c: Add location
argument to fold_{unary,binary,ternary}, fold_build[123],
build_call_expr, build_size_arg, build_fold_addr_expr,
build_call_array, non_lvalue, size_diffop,
fold_build1_initializer, fold_build2_initializer,
fold_build3_initializer, fold_build_call_array,
fold_build_call_array_initializer, fold_single_bit_test,
omit_one_operand, omit_two_operands, invert_truthvalue,
fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref,
combine_comparisons, fold_builtin_*, fold_call_expr,
build_range_check, maybe_fold_offset_to_address, round_up,
round_down.
objc/
* objc-act.c: Add location argument to all calls to
build_fold_addr_expr.
testsuite/
* gcc.dg/pr36902.c: Add column info.
* g++.dg/gcov/gcov-2.C: Change count for definition.
cp/
* typeck.c, init.c, class.c, method.c, rtti.c, except.c, error.c,
tree.c, cp-gimplify.c, cxx-pretty-print.c, pt.c, semantics.c,
call.c, cvt.c, mangle.c: Add location argument to
fold_{unary,binary,ternary}, fold_build[123], build_call_expr,
build_size_arg, build_fold_addr_expr, build_call_array,
non_lvalue, size_diffop, fold_build1_initializer,
fold_build2_initializer, fold_build3_initializer,
fold_build_call_array, fold_build_call_array_initializer,
fold_single_bit_test, omit_one_operand, omit_two_operands,
invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref,
fold_indirect_ref, combine_comparisons, fold_builtin_*,
fold_call_expr, build_range_check, maybe_fold_offset_to_address,
round_up, round_down.
fortran/
* trans-expr.c, trans-array.c, trans-openmp.c, trans-stmt.c,
trans.c, trans-io.c, trans-decl.c, trans-intrinsic.c: Add location
argument to fold_{unary,binary,ternary}, fold_build[123],
build_call_expr, build_size_arg, build_fold_addr_expr,
build_call_array, non_lvalue, size_diffop,
fold_build1_initializer, fold_build2_initializer,
fold_build3_initializer, fold_build_call_array,
fold_build_call_array_initializer, fold_single_bit_test,
omit_one_operand, omit_two_operands, invert_truthvalue,
fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref,
combine_comparisons, fold_builtin_*, fold_call_expr,
build_range_check, maybe_fold_offset_to_address, round_up,
round_down.
Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>
From-SVN: r149722
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 069452c..3aa8ed9 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1086,6 +1086,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const) tree eptype = NULL_TREE; bool dummy = true; bool maybe_const_itself = true; + location_t loc = EXPR_LOCATION (expr); /* This function is not relevant to C++ because C++ folds while parsing, and may need changes to be correct for C++ when C++ @@ -1103,7 +1104,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const) ret = c_fully_fold_internal (expr, in_init, maybe_const, &maybe_const_itself); if (eptype) - ret = fold_convert (eptype, ret); + ret = fold_convert_loc (loc, eptype, ret); *maybe_const &= maybe_const_itself; return ret; } @@ -1300,8 +1301,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = decl_constant_value_for_optimization (op1); if (op0 != orig_op0 || op1 != orig_op1 || in_init) ret = in_init - ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1) - : fold_build2 (code, TREE_TYPE (expr), op0, op1); + ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1) + : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1); else ret = fold (expr); goto out; @@ -1326,8 +1327,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op0 = decl_constant_value_for_optimization (op0); if (op0 != orig_op0 || in_init) ret = in_init - ? fold_build1_initializer (code, TREE_TYPE (expr), op0) - : fold_build1 (code, TREE_TYPE (expr), op0); + ? fold_build1_initializer_loc (loc, code, TREE_TYPE (expr), op0) + : fold_build1_loc (loc, code, TREE_TYPE (expr), op0); else ret = fold (expr); if (code == INDIRECT_REF @@ -1350,8 +1351,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); if (op0 != orig_op0 || op1 != orig_op1 || in_init) ret = in_init - ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1) - : fold_build2 (code, TREE_TYPE (expr), op0, op1); + ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1) + : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1); else ret = fold (expr); *maybe_const_operands &= op0_const; @@ -1379,7 +1380,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); op2 = c_fully_fold_internal (op2, in_init, &op2_const, &op2_const_self); if (op0 != orig_op0 || op1 != orig_op1 || op2 != orig_op2) - ret = fold_build3 (code, TREE_TYPE (expr), op0, op1, op2); + ret = fold_build3_loc (loc, code, TREE_TYPE (expr), op0, op1, op2); else ret = fold (expr); *maybe_const_operands &= op0_const; @@ -1620,7 +1621,8 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, if (lhs && rhs && operand_equal_p (lhs, rhs, 0) && merge_ranges (&in_p, &low, &high, in0_p, low0, high0, in1_p, low1, high1) - && 0 != (tem = build_range_check (type, lhs, in_p, low, high))) + && 0 != (tem = build_range_check (UNKNOWN_LOCATION, + type, lhs, in_p, low, high))) { if (TREE_CODE (tem) != INTEGER_CST) return; @@ -3658,7 +3660,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, of pointer PTROP and integer INTOP. */ tree -pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) +pointer_int_sum (location_t loc, enum tree_code resultcode, + tree ptrop, tree intop) { tree size_exp, ret; @@ -3667,19 +3670,19 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer of type %<void *%> used in arithmetic"); size_exp = integer_one_node; } else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to a function used in arithmetic"); size_exp = integer_one_node; } else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to member function used in arithmetic"); size_exp = integer_one_node; } @@ -3734,15 +3737,15 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) Do this multiplication as signed, then convert to the appropriate type for the pointer operation. */ intop = convert (sizetype, - build_binary_op (EXPR_LOCATION (intop), + build_binary_op (loc, MULT_EXPR, intop, convert (TREE_TYPE (intop), size_exp), 1)); /* Create the sum or difference. */ if (resultcode == MINUS_EXPR) - intop = fold_build1 (NEGATE_EXPR, sizetype, intop); + intop = fold_build1_loc (loc, NEGATE_EXPR, sizetype, intop); - ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop); + ret = fold_build2_loc (loc, POINTER_PLUS_EXPR, result_type, ptrop, intop); fold_undefer_and_ignore_overflow_warnings (); @@ -3925,7 +3928,7 @@ c_common_truthvalue_conversion (location_t location, tree expr) /* Distribute the conversion into the arms of a COND_EXPR. */ if (c_dialect_cxx ()) { - expr = fold_build3 (COND_EXPR, truthvalue_type_node, + expr = fold_build3_loc (location, COND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 0), c_common_truthvalue_conversion (location, TREE_OPERAND (expr, @@ -4290,9 +4293,9 @@ c_sizeof_or_alignof_type (location_t loc, { if (is_sizeof) /* Convert in case a char is more than one unit. */ - value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), - size_int (TYPE_PRECISION (char_type_node) - / BITS_PER_UNIT)); + value = size_binop_loc (loc, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), + size_int (TYPE_PRECISION (char_type_node) + / BITS_PER_UNIT)); else value = size_int (TYPE_ALIGN_UNIT (type)); } @@ -4301,7 +4304,7 @@ c_sizeof_or_alignof_type (location_t loc, TYPE_IS_SIZETYPE means that certain things (like overflow) will never happen. However, this node should really have type `size_t', which is just a typedef for an ordinary integer type. */ - value = fold_convert (size_type_node, value); + value = fold_convert_loc (loc, size_type_node, value); gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value))); return value; @@ -4352,7 +4355,7 @@ c_alignof_expr (location_t loc, tree expr) else return c_alignof (loc, TREE_TYPE (expr)); - return fold_convert (size_type_node, t); + return fold_convert_loc (loc, size_type_node, t); } /* Handle C and C++ default attributes. */ @@ -5628,11 +5631,11 @@ boolean_increment (enum tree_code code, tree arg) break; case PREDECREMENT_EXPR: val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, - invert_truthvalue (arg)); + invert_truthvalue_loc (input_location, arg)); break; case POSTDECREMENT_EXPR: val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, - invert_truthvalue (arg)); + invert_truthvalue_loc (input_location, arg)); arg = save_expr (arg); val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), val, arg); val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val); @@ -8357,9 +8360,10 @@ fold_offsetof_1 (tree expr, tree stop_ref) "member %qD", t); return error_mark_node; } - off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t), - size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), 1) - / BITS_PER_UNIT)); + off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t), + size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), + 1) + / BITS_PER_UNIT)); break; case ARRAY_REF: @@ -8371,7 +8375,7 @@ fold_offsetof_1 (tree expr, tree stop_ref) if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) < 0) { code = MINUS_EXPR; - t = fold_build1 (NEGATE_EXPR, TREE_TYPE (t), t); + t = fold_build1_loc (input_location, NEGATE_EXPR, TREE_TYPE (t), t); } t = convert (sizetype, t); off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t); @@ -8464,9 +8468,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) bool fold_p = false; if (VEC_index (constructor_elt, v, 0)->index) - maxindex = fold_convert (sizetype, - VEC_index (constructor_elt, - v, 0)->index); + maxindex = fold_convert_loc (input_location, sizetype, + VEC_index (constructor_elt, + v, 0)->index); curindex = maxindex; for (cnt = 1; @@ -8480,7 +8484,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) { if (fold_p) curindex = fold_convert (sizetype, curindex); - curindex = size_binop (PLUS_EXPR, curindex, size_one_node); + curindex = size_binop (PLUS_EXPR, curindex, + size_one_node); } if (tree_int_cst_lt (maxindex, curindex)) maxindex = curindex, fold_p = curfold_p; |