diff options
author | Martin Sebor <msebor@redhat.com> | 2018-06-19 22:35:45 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-06-19 16:35:45 -0600 |
commit | b5ebb71777112f2575c4abfc94439c7c9f13210e (patch) | |
tree | 518f9ef5ba978ce1e314d289d6ba5b5ba69bb930 /gcc | |
parent | 180720a5619f319261b28871eb6228063c3b1164 (diff) | |
download | gcc-b5ebb71777112f2575c4abfc94439c7c9f13210e.zip gcc-b5ebb71777112f2575c4abfc94439c7c9f13210e.tar.gz gcc-b5ebb71777112f2575c4abfc94439c7c9f13210e.tar.bz2 |
PR middle-end/85602 - -Warray-bounds fails to detect the out of bound array access
gcc/testsuite/ChangeLog:
* c-c++-common/attr-nonstring-8.c: Adjust text of expected warning
to also match C++.
From-SVN: r261774
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-28.c | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04da05d..5ce5b61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2018-06-19 Martin Sebor <msebor@redhat.com> + PR tree-optimization/48560 + * gcc.dg/Warray-bounds-28.c: New test. + +2018-06-19 Martin Sebor <msebor@redhat.com> + PR middle-end/85602 * c-c++-common/attr-nonstring-8.c: Adjust text of expected warning to also match C++. diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-28.c b/gcc/testsuite/gcc.dg/Warray-bounds-28.c new file mode 100644 index 0000000..c63c70a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-28.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/48560 - -Warray-bounds fails to detect the out of + bound array access + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +char foo1 (int i) +{ + static char s[] = "foo"; + switch (i) + { + case 30: + return s[30]; /* { dg-warning "array subscript 30 is above array bounds" } */ + } + return s[i]; +} |