aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-11-05 08:43:46 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-11-05 08:43:46 +0000
commit175a31e4914dc8814c08f8961daf0d419e2f0cb7 (patch)
treefda2612f278a31e0d9c9a50272d15ddda7468e2b /gcc
parent7f77442bdff6a81e128f5786001b229c5fc7c8d8 (diff)
downloadgcc-175a31e4914dc8814c08f8961daf0d419e2f0cb7.zip
gcc-175a31e4914dc8814c08f8961daf0d419e2f0cb7.tar.gz
gcc-175a31e4914dc8814c08f8961daf0d419e2f0cb7.tar.bz2
loadpre2.c: Avoid undefined behavior due to uninitialized variables.
2015-11-05 Richard Biener <rguenther@suse.de> * gcc.dg/tree-ssa/loadpre2.c: Avoid undefined behavior due to uninitialized variables. * gcc.dg/tree-ssa/loadpre21.c: Likewise. * gcc.dg/tree-ssa/loadpre22.c: Likewise. * gcc.dg/tree-ssa/loadpre23.c: Likewise. * gcc.dg/tree-ssa/loadpre24.c: Likewise. * gcc.dg/tree-ssa/loadpre25.c: Likewise. * gcc.dg/tree-ssa/loadpre4.c: Likewise. * gcc.dg/ipa/inlinehint-2.c: Likewise. * gcc.dg/ipa/pure-const-2.c: Likewise. * gcc.dg/tree-ssa/loop-1.c: Likewise. * gcc.dg/tree-ssa/loop-23.c: Likewise. * gcc.dg/tree-ssa/pr22051-2.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-3.c: Likewise. * gcc.dg/tree-ssa/ssa-sccvn-3.c: Likewise. * gcc.dg/vect/pr30858.c: Likewise. * gcc.dg/vect/pr33866.c: Likewise. * gcc.dg/vect/pr37027.c: Likewise. * c-c++-common/ubsan/null-10.c: Likewise. * gcc.target/i386/incoming-8.c: Likewise. From-SVN: r229793
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog23
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/null-10.c4
-rw-r--r--gcc/testsuite/gcc.dg/ipa/inlinehint-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pure-const-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre2.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre21.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre22.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre23.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre24.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre25.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loadpre4.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-23.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr22051-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-3.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-sccvn-3.c6
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr30858.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr33866.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr37027.c4
-rw-r--r--gcc/testsuite/gcc.target/i386/incoming-8.c2
20 files changed, 55 insertions, 44 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1733e60..98d481e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,26 @@
+2015-11-05 Richard Biener <rguenther@suse.de>
+
+ * gcc.dg/tree-ssa/loadpre2.c: Avoid undefined behavior due to
+ uninitialized variables.
+ * gcc.dg/tree-ssa/loadpre21.c: Likewise.
+ * gcc.dg/tree-ssa/loadpre22.c: Likewise.
+ * gcc.dg/tree-ssa/loadpre23.c: Likewise.
+ * gcc.dg/tree-ssa/loadpre24.c: Likewise.
+ * gcc.dg/tree-ssa/loadpre25.c: Likewise.
+ * gcc.dg/tree-ssa/loadpre4.c: Likewise.
+ * gcc.dg/ipa/inlinehint-2.c: Likewise.
+ * gcc.dg/ipa/pure-const-2.c: Likewise.
+ * gcc.dg/tree-ssa/loop-1.c: Likewise.
+ * gcc.dg/tree-ssa/loop-23.c: Likewise.
+ * gcc.dg/tree-ssa/pr22051-2.c: Likewise.
+ * gcc.dg/tree-ssa/ssa-pre-3.c: Likewise.
+ * gcc.dg/tree-ssa/ssa-sccvn-3.c: Likewise.
+ * gcc.dg/vect/pr30858.c: Likewise.
+ * gcc.dg/vect/pr33866.c: Likewise.
+ * gcc.dg/vect/pr37027.c: Likewise.
+ * c-c++-common/ubsan/null-10.c: Likewise.
+ * gcc.target/i386/incoming-8.c: Likewise.
+
2015-11-04 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/slice9.adb: New test.
diff --git a/gcc/testsuite/c-c++-common/ubsan/null-10.c b/gcc/testsuite/c-c++-common/ubsan/null-10.c
index 2ff9485..705e00d 100644
--- a/gcc/testsuite/c-c++-common/ubsan/null-10.c
+++ b/gcc/testsuite/c-c++-common/ubsan/null-10.c
@@ -2,10 +2,12 @@
/* { dg-options "-fsanitize=null -w" } */
/* { dg-shouldfail "ubsan" } */
+short x;
+
int
main (void)
{
- short *p = 0, *u;
+ short *p = 0, *u = &x;
*(u + *p) = 23;
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-2.c b/gcc/testsuite/gcc.dg/ipa/inlinehint-2.c
index cfdcb24..500100d 100644
--- a/gcc/testsuite/gcc.dg/ipa/inlinehint-2.c
+++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-2.c
@@ -5,7 +5,7 @@ int
t(int s, void **p)
{
int i;
- for (i;i<10000;i+=s)
+ for (i=0;i<10000;i+=s)
p[i]=0;
}
int
diff --git a/gcc/testsuite/gcc.dg/ipa/pure-const-2.c b/gcc/testsuite/gcc.dg/ipa/pure-const-2.c
index 51d7797..564a59c 100644
--- a/gcc/testsuite/gcc.dg/ipa/pure-const-2.c
+++ b/gcc/testsuite/gcc.dg/ipa/pure-const-2.c
@@ -5,7 +5,7 @@ int i_am_pure(char *c, int n)
{
char *d=__builtin_alloca (n);
int i;
- int sum;
+ int sum = 0;
for (i=0;i<n;i++)
d[i] = c[i];
for (i=0;i<n;i++)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre2.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre2.c
index 7e699c9..1ef0484 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre2.c
@@ -2,16 +2,15 @@
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int main(int *a, int argc)
{
- int b;
int i;
- int d, e;
+ int e;
/* Should be able to hoist this out of the loop. */
for (i = 0; i < argc; i++)
{
e = *a;
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre21.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre21.c
index 3ee16c3..e285191 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre21.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre21.c
@@ -3,16 +3,15 @@
typedef int type[2];
int main(type *a, int argc)
{
- int b;
int i;
- int d, e;
+ int e;
/* Should be able to hoist this out of the loop. */
for (i = 0; i < argc; i++)
{
e = (*a)[0];
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre22.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre22.c
index acd389b..62809c3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre22.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre22.c
@@ -3,16 +3,15 @@
typedef int type[2];
int main(type *a, int argc)
{
- int b;
int i;
- int d, e;
+ int e;
/* Should be able to hoist this out of the loop. */
for (i = 0; i < argc; i++)
{
e = (*a)[argc];
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre23.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre23.c
index 1a62bc4..9fa0731 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre23.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre23.c
@@ -8,17 +8,16 @@ struct {
int foo(int argc)
{
- int b;
int c;
int i;
- int d, e;
+ int e;
for (i = 0; i < argc; i++)
{
e = x.a;
x.a = 9;
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre24.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre24.c
index 5bf7b50..bd7275f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre24.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre24.c
@@ -5,17 +5,15 @@ int a;
int foo(int argc)
{
- int b;
- int c;
int i;
- int d, e;
+ int e;
for (i = 0; i < argc; i++)
{
e = a;
a = 9;
}
- return d + e;
+ return e;
}
/* We will move the load of a out of the loop. */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre25.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre25.c
index 9cdb003..8418c30 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre25.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre25.c
@@ -3,17 +3,15 @@
struct X { int i; };
int foo(struct X *a, int argc)
{
- int b;
- int c;
int i;
- int d, e;
+ int e;
for (i = 0; i < argc; i++)
{
e = a->i;
a->i = 9;
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loadpre4.c b/gcc/testsuite/gcc.dg/tree-ssa/loadpre4.c
index 48630c8..2ca7e39 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loadpre4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loadpre4.c
@@ -2,17 +2,15 @@
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
int main(int *a, int argc)
{
- int b;
- int c;
int i;
- int d, e;
+ int e;
for (i = 0; i < argc; i++)
{
e = *a;
*a = 9;
}
- return d + e;
+ return e;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
index 9d18dd7..0193c6e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-1.c
@@ -24,7 +24,7 @@ int foo (int x);
int xxx(void)
{
int x = 45;
- int sum;
+ int sum = 0;
while (x >>= 1)
sum += foo (x) * 2;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-23.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-23.c
index 3c88484..50ae1a8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-23.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-23.c
@@ -7,7 +7,7 @@ int bla(int);
int foo(void)
{
int i;
- int sum;
+ int sum = 0;
/* This loop used to appear to be too large for unrolling. */
for (i = 0; i < 4; i++)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr22051-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr22051-2.c
index cae9a06..98114f3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr22051-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr22051-2.c
@@ -1,14 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized -w" } */
-
-
-
void *arf ();
int
-foo()
+foo(void (*q)(void))
{
- void (*q)(void);
int r = q;
if (r != 0)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-3.c
index 0af5342..ba2c8ea 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-3.c
@@ -1,8 +1,8 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
-unsigned foo1 (unsigned a, unsigned b)
+unsigned foo1 (unsigned a, unsigned b, unsigned j, unsigned k)
{
- unsigned i, j, k;
+ unsigned i;
for (i = 0; i != a; i++)
{
j += 4*b;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sccvn-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sccvn-3.c
index 4284d89..9040ff8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sccvn-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sccvn-3.c
@@ -1,8 +1,8 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-fre1-stats" } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+int *p;
int main(int argc, char **argv)
{
- int *p;
int result;
*p = 2;
if (argc)
@@ -11,4 +11,4 @@ int main(int argc, char **argv)
return result;
}
/* We should eliminate result = *p by saying it has the value 2. */
-/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "fre1"} } */
+/* { dg-final { scan-tree-dump "return 2;" "fre1"} } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr30858.c b/gcc/testsuite/gcc.dg/vect/pr30858.c
index 35a6a8d..cc92318 100644
--- a/gcc/testsuite/gcc.dg/vect/pr30858.c
+++ b/gcc/testsuite/gcc.dg/vect/pr30858.c
@@ -4,7 +4,7 @@
int
foo (int ko)
{
- int j,i;
+ int j,i = 0;
for (j = 0; j < ko; j++)
i += (i > 10) ? -5 : 7;
return i;
diff --git a/gcc/testsuite/gcc.dg/vect/pr33866.c b/gcc/testsuite/gcc.dg/vect/pr33866.c
index ddb1287..737b2e8 100644
--- a/gcc/testsuite/gcc.dg/vect/pr33866.c
+++ b/gcc/testsuite/gcc.dg/vect/pr33866.c
@@ -18,7 +18,7 @@ void test_select_fill_hyper_simple (long *offset)
fill_iter_info iter_info;
int i, j;
iter_info.coords = (long *) points;
- for (i = 0, num_points = 0; j < (int) start[1]; j++, num_points++)
+ for (j = i = 0, num_points = 0; j < (int) start[1]; j++, num_points++)
{
points[num_points][0] = i + start[0];
points[num_points][1] = j + start[1];
diff --git a/gcc/testsuite/gcc.dg/vect/pr37027.c b/gcc/testsuite/gcc.dg/vect/pr37027.c
index 8c83f01..ef6760e 100644
--- a/gcc/testsuite/gcc.dg/vect/pr37027.c
+++ b/gcc/testsuite/gcc.dg/vect/pr37027.c
@@ -18,8 +18,8 @@ void
foo (void)
{
int i;
- int sum1;
- int sum2;
+ int sum1 = 0;
+ int sum2 = 0;
for (i = 0; i < 16; i++)
{
diff --git a/gcc/testsuite/gcc.target/i386/incoming-8.c b/gcc/testsuite/gcc.target/i386/incoming-8.c
index 61d9cb3..a9912d1 100644
--- a/gcc/testsuite/gcc.target/i386/incoming-8.c
+++ b/gcc/testsuite/gcc.target/i386/incoming-8.c
@@ -6,7 +6,7 @@ float
foo (float f)
{
float array[128];
- float x;
+ float x = 0.;
int i;
for (i = 0; i < sizeof(array) / sizeof(*array); i++)
array[i] = f;