From 6906ea8b518ac22b31df5d11d27a82c6f01850ca Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 23 Aug 2018 19:39:18 +0000 Subject: [PATCH] PR tree-optimization/87072 - false warning: array subscript is above array bounds gcc/testsuite/ChangeLog: * gcc.dg/Warray-bounds-35.c: New test. From-SVN: r263822 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/Warray-bounds-35.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Warray-bounds-35.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf2295bcdea..e83279f7f9b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-23 Martin Sebor + + PR tree-optimization/87072 + * gcc.dg/Warray-bounds-35.c: New test. + 2018-08-23 Richard Biener PR middle-end/87024 diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-35.c b/gcc/testsuite/gcc.dg/Warray-bounds-35.c new file mode 100644 index 00000000000..b3ad3625206 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-35.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/87072 - g++6.2.0 false warning: array subscript + is above array bounds, with misleading line number + { dg-do compile } + { dg-options "-O3 -Wall" } */ + +int a[10]; + +void f (unsigned n) +{ + for (unsigned j = 0; j < n; j++) { + for (unsigned k = 0; k < j; k++) + a[j] += k; /* { dg-bogus "\\\[-Warray-bounds]" } */ + a[j] += j; + } +} -- 2.30.2