diff options
author | Martin Sebor <msebor@redhat.com> | 2017-12-18 03:31:05 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2017-12-17 20:31:05 -0700 |
commit | 56735d40cafbfb1cf1d4bb052480372b020d98f5 (patch) | |
tree | 9990691398d0dd363ddc5bdd23fddbcce5f3e51f /gcc | |
parent | bfecb9de2d882681278a9b4525566f665605312d (diff) | |
download | gcc-56735d40cafbfb1cf1d4bb052480372b020d98f5.zip gcc-56735d40cafbfb1cf1d4bb052480372b020d98f5.tar.gz gcc-56735d40cafbfb1cf1d4bb052480372b020d98f5.tar.bz2 |
PR bootstrap/83446 - Bootstrap failed on i686
gcc/testsuite/ChangeLog:
PR bootstrap/83446
* c-c++-common/Warray-bounds-3.c: Adjust.
* gcc.dg/Warray-bounds-25.c: New test.
gcc/ChangeLog:
PR bootstrap/83446
* gimple-ssa-warn-restrict.c
(builtin_memref::offset_out_of_bounds): Correct the handling of
anti-ranges.
From-SVN: r255772
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/gimple-ssa-warn-restrict.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Warray-bounds-3.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-25.c | 33 |
4 files changed, 48 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b6b677..13b8cc7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-12-17 Martin Sebor <msebor@redhat.com> + + PR bootstrap/83446 + * gimple-ssa-warn-restrict.c + (builtin_memref::offset_out_of_bounds): Correct the handling of + anti-ranges. + 2017-12-17 Sandra Loosemore <sandra@codesourcery.com> * doc/invoke.texi (ARC Options): Add missing -mlra entry. diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index f524e1d..4d42473 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -413,7 +413,9 @@ builtin_memref::offset_out_of_bounds (int strict, offset_int ooboff[2]) const if (DECL_P (base) && TREE_CODE (TREE_TYPE (base)) == ARRAY_TYPE) { - if (offrng[1] < offrng[0]) + /* Check for offset in an anti-range with a negative lower bound. + For such a range, consider only the non-negative subrange. */ + if (offrng[1] < offrng[0] && offrng[1] < 0) offrng[1] = maxobjsize; } diff --git a/gcc/testsuite/c-c++-common/Warray-bounds-3.c b/gcc/testsuite/c-c++-common/Warray-bounds-3.c index 8bb4f1c..85c8f6a 100644 --- a/gcc/testsuite/c-c++-common/Warray-bounds-3.c +++ b/gcc/testsuite/c-c++-common/Warray-bounds-3.c @@ -123,8 +123,11 @@ void test_memcpy_bounds_anti_range (char *d, const char *s, size_t n) (yet). */ T (char, 9, a, a + SAR ( 1, 6), 3); /* { dg-warning "forming offset \\\[9, 0] is out of the bounds \\\[0, 9] of object " "memcpy" { xfail *-*-* } } */ - T (char, 9, a, a + SAR ( 2, 6), 3); /* { dg-warning "forming offset 10 is out of the bounds \\\[0, 9] of object " "memcpy" } */ - T (char, 9, a, a + SAR ( 3, 6), 3); /* { dg-warning "forming offset 10 is out of the bounds \\\[0, 9] of object " "memcpy" } */ + /* The range of offsets is the union of [0, 1] and [7, PTRDIFF_MAX] + of which the first subrange is valid and thus no warming for memcpy + is issued. Similarly for the next test. */ + T (char, 9, a, a + SAR ( 2, 6), 3); + T (char, 9, a, a + SAR ( 3, 6), 3); T (char, 9, a, a + SAR (-1, 7), 3); /* { dg-warning "forming offset \\\[10, 11] is out of the bounds \\\[0, 9] of object " "memcpy" } */ T (char, 9, a, a + SAR (-2, 8), 3); /* { dg-warning "forming offset \\\[10, 12] is out of the bounds \\\[0, 9] of object " "memcpy" } */ diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-25.c b/gcc/testsuite/gcc.dg/Warray-bounds-25.c new file mode 100644 index 0000000..37fb9cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-25.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/83446 - Bootstrap failed on i686 + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +char a[4]; + +void f0i (void *d, int n) +{ + if (n < 0) n = 0; + + __builtin_memcpy (d, a + sizeof a - n, n); +} + +void f0L (void *d, long n) +{ + if (n < 0) n = 0; + + __builtin_memcpy (d, a + sizeof a - n, n); +} + +void f0u (void *d, unsigned n) +{ + if (n < 0) n = 1; + + __builtin_memcpy (d, a + sizeof a - n, n); /* { dg-bogus "\\\[-Warray-bounds" } */ +} + +void f1lu (void *d, unsigned long n) +{ + if (n < 1) n = 1; + + __builtin_memcpy (d, a + sizeof a - n, n); /* { dg-bogus "\\\[-Warray-bounds" } */ +} |