diff options
author | Martin Sebor <msebor@redhat.com> | 2018-12-20 16:25:13 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-12-20 09:25:13 -0700 |
commit | ab3c292e600b31177c8ddfe1e7a1cda255d39321 (patch) | |
tree | bac0c2cd86b3fe596054af690d84df67cffc3e94 /gcc | |
parent | 573767d4d2cbea5ba5c6de753455055fe4de355d (diff) | |
download | gcc-ab3c292e600b31177c8ddfe1e7a1cda255d39321.zip gcc-ab3c292e600b31177c8ddfe1e7a1cda255d39321.tar.gz gcc-ab3c292e600b31177c8ddfe1e7a1cda255d39321.tar.bz2 |
PR tree-optimization/84053 - missing -Warray-bounds accessing a local array across inlined function boundaries
gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-36.c: New test.
From-SVN: r267302
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-36.c | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61aa13b..2a78f97 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-20 Martin Sebor <msebor@redhat.com> + + PR tree-optimization/84053 + * gcc.dg/Warray-bounds-36.c: New test. + 2018-12-20 David Malcolm <dmalcolm@redhat.com> PR c++/87504 diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-36.c b/gcc/testsuite/gcc.dg/Warray-bounds-36.c new file mode 100644 index 0000000..35b3c92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-36.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/84053] missing -Warray-bounds accessing + a local array across inlined function boundaries + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int deref (const int *p, int i) +{ + return p[i]; // { dg-warning "array subscript \\\[3, \[0-9\]+] is outside array bounds of .int\\\[2\\\]." "ilp33" { xfail ilp32 } } + + // There should also be an inlining context here. PR 86650 tracks + // its absence. +} + +int deref_3_plus (const int *p, int i) +{ + if (i < 3) + i = 3; + + return deref (p, i); +} + +int deref_a (int i) +{ + int a[] = { 2, 3 }; + + return deref_3_plus (a, i); +} |