summaryrefslogtreecommitdiffstats
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-28 04:56:47 +0000
committerbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-28 04:56:47 +0000
commit1f63a7d666901121bd8e1a65478855d735fac9a0 (patch)
treea7b2e8cf678fd319d296b231776140e3a5a093d0 /gcc/builtins.c
parent48e08ee00c39fadc48298b556b6fbcf04bdd9f02 (diff)
downloadppe42-gcc-1f63a7d666901121bd8e1a65478855d735fac9a0.tar.gz
ppe42-gcc-1f63a7d666901121bd8e1a65478855d735fac9a0.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146870 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8621e0db511..067e3116faf 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -479,13 +479,16 @@ c_strlen (tree src, int only_value)
else
offset = tree_low_cst (offset_node, 0);
- /* If the offset is known to be out of bounds, the front-end should
- have warned already. We call strlen at runtime.
-
- ??? Perhaps we should turn this into an assert and force
- front-ends to define offsets whtin boundaries. */
+ /* If the offset is known to be out of bounds, warn, and call strlen at
+ runtime. */
if (offset < 0 || offset > max)
{
+ /* Suppress multiple warnings for propagated constant strings. */
+ if (! TREE_NO_WARNING (src))
+ {
+ warning (0, "offset outside bounds of constant string");
+ TREE_NO_WARNING (src) = 1;
+ }
return NULL_TREE;
}
OpenPOWER on IntegriCloud