aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite
diff options
context:
space:
mode:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>2015-01-28 11:16:01 (GMT)
committerAlexander Ivchenko <alexander.ivchenko@intel.com>2015-01-28 12:41:39 (GMT)
commit63fd708bd182b50b37b9f64fa330458c9109380a (patch)
tree2799a45bf3f48cd9f4039d79aa82b5c0b2189f6a /gcc-4.9/gcc/testsuite
parent866bd0b46cd84957df84e7a3e674d9777807b7f7 (diff)
downloadtoolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.zip
toolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.tar.gz
toolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.tar.bz2
[4.9] Fix bogus warnings about array-bounds.
2015-01-28 Ilya Enkovich <ilya.enkovich@intel.com> PR tree-optimization/64277 * tree-ssa-loop-niter.c (record_nonwrapping_iv): Use base range info when possible to refine estimation. 2015-01-27 Richard Biener <rguenther@suse.de> PR tree-optimization/56273 PR tree-optimization/59124 PR tree-optimization/64277 * tree-vrp.c (vrp_finalize): Emit array-bound warnings only from the first VRP pass. * g++.dg/warn/Warray-bounds-6.C: New testcase. * gcc.dg/Warray-bounds-12.c: Likewise. * gcc.dg/Warray-bounds-13.c: Likewise. Change-Id: I175b420a4c8150ecf986d477e4c51cbbff276c82 Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
Diffstat (limited to 'gcc-4.9/gcc/testsuite')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-12.c26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-13.c18
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/pr64277.c23
4 files changed, 93 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C b/gcc-4.9/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
new file mode 100644
index 0000000..f2e5f2f
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// { dg-options "-O3 -Warray-bounds" }
+
+struct type {
+ bool a, b;
+ bool get_b() { return b; }
+};
+
+type stuff[9u];
+
+void bar();
+
+void foo()
+{
+ for(unsigned i = 0u; i < 9u; i++)
+ {
+ if(!stuff[i].a)
+ continue;
+
+ bar();
+
+ for(unsigned j = i + 1u; j < 9u; j++)
+ if(stuff[j].a && stuff[j].get_b()) // { dg-bogus "above array bounds" }
+ return;
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-12.c b/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-12.c
new file mode 100644
index 0000000..ef26c65
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-12.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds" } */
+/* { dg-additional-options "-mssse3" { target x86_64-*-* i?86-*-* } } */
+
+void foo(short a[], short m)
+{
+ int i, j;
+ int f1[10];
+ short nc;
+
+ nc = m + 1;
+ if (nc > 3)
+ {
+ for (i = 0; i <= nc; i++)
+ {
+ f1[i] = f1[i] + 1;
+ }
+ }
+
+ for (i = 0, j = m; i < nc; i++, j--)
+ {
+ a[i] = f1[i]; /* { dg-bogus "above array bounds" } */
+ a[j] = i;
+ }
+ return;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-13.c b/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-13.c
new file mode 100644
index 0000000..7b40a83
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/Warray-bounds-13.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds" } */
+
+extern char *bar[17];
+
+int foo(int argc, char **argv)
+{
+ int i;
+ int n = 0;
+
+ for (i = 0; i < argc; i++)
+ n++;
+
+ for (i = 0; i < argc; i++)
+ argv[i] = bar[i + n]; /* { dg-bogus "above array bounds" } */
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/pr64277.c b/gcc-4.9/gcc/testsuite/gcc.dg/pr64277.c
new file mode 100644
index 0000000..c6ef331
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/pr64277.c
@@ -0,0 +1,23 @@
+/* PR tree-optimization/64277 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -Wall -Werror -fdump-tree-cunroll-details" } */
+/* { dg-final { scan-tree-dump "loop with 5 iterations completely unrolled" "cunroll" } } */
+/* { dg-final { scan-tree-dump "loop with 6 iterations completely unrolled" "cunroll" } } */
+/* { dg-final { cleanup-tree-dump "cunroll" } } */
+
+int f1[10];
+void test1 (short a[], short m, unsigned short l)
+{
+ int i = l;
+ for (i = i + 5; i < m; i++)
+ f1[i] = a[i]++;
+}
+
+void test2 (short a[], short m, short l)
+{
+ int i;
+ if (m > 5)
+ m = 5;
+ for (i = m; i > l; i--)
+ f1[i] = a[i]++;
+}