diff options
author | Ben Elliston <bje@au.ibm.com> | 2009-04-28 04:56:47 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2009-04-28 14:56:47 +1000 |
commit | b2ed71b61a5f8a7d8c001516af6997d3fcaff403 (patch) | |
tree | a7b2e8cf678fd319d296b231776140e3a5a093d0 /gcc/c-common.c | |
parent | 903db43579c8059fb643086c5492e7c58f702bfe (diff) | |
download | gcc-b2ed71b61a5f8a7d8c001516af6997d3fcaff403.zip gcc-b2ed71b61a5f8a7d8c001516af6997d3fcaff403.tar.gz gcc-b2ed71b61a5f8a7d8c001516af6997d3fcaff403.tar.bz2 |
revert: re PR c++/35652 (offset warning should be given in the front-end)
Revert:
PR c++/35652
2009-03-27 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
gcc/
* builtins.c (c_strlen): Do not warn here.
* c-typeck.c (build_binary_op): Adjust calls to pointer_int_sum.
* c-common.c (pointer_int_sum): Take an explicit location.
Warn about offsets out of bounds.
* c-common.h (pointer_int_sum): Adjust declaration.
cp/
* typeck.c (cp_pointer_sum): Adjust call to pointer_int_sum.
testsuite/
* gcc.dg/pr35652.C: New.
* g++.dg/warn/pr35652.C: New.
* gcc.dg/format/plus-1.c: Adjust message.
From-SVN: r146870
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 67fe8ad..7ee7a09 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3767,8 +3767,7 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, of pointer PTROP and integer INTOP. */ tree -pointer_int_sum (location_t location, enum tree_code resultcode, - tree ptrop, tree intop) +pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) { tree size_exp, ret; @@ -3777,19 +3776,19 @@ pointer_int_sum (location_t location, enum tree_code resultcode, if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) { - pedwarn (location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (input_location, 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 (location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (input_location, 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 (location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to member function used in arithmetic"); size_exp = integer_one_node; } @@ -3852,31 +3851,6 @@ pointer_int_sum (location_t location, enum tree_code resultcode, if (resultcode == MINUS_EXPR) intop = fold_build1 (NEGATE_EXPR, sizetype, intop); - if (TREE_CODE (intop) == INTEGER_CST) - { - tree offset_node; - tree string_cst = string_constant (ptrop, &offset_node); - - if (string_cst != 0 - && !(offset_node && TREE_CODE (offset_node) != INTEGER_CST)) - { - HOST_WIDE_INT max = TREE_STRING_LENGTH (string_cst); - HOST_WIDE_INT offset; - if (offset_node == 0) - offset = 0; - else if (! host_integerp (offset_node, 0)) - offset = -1; - else - offset = tree_low_cst (offset_node, 0); - - offset = offset + tree_low_cst (intop, 0); - if (offset < 0 || offset > max) - warning_at (location, 0, - "offset %<%wd%> outside bounds of constant string", - tree_low_cst (intop, 0)); - } - } - ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop); fold_undefer_and_ignore_overflow_warnings (); |