aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-12-08 14:45:30 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-12-08 14:45:30 +0000
commit68e6d5a6bdd07248e78eccbd19eb282a9531fd7c (patch)
treecab7b6a3f4bab57135917c736bfa2bee10fc9c26 /gcc
parent4f29e04064c39dfdc23831e41328f5ba84195957 (diff)
downloadgcc-68e6d5a6bdd07248e78eccbd19eb282a9531fd7c.zip
gcc-68e6d5a6bdd07248e78eccbd19eb282a9531fd7c.tar.gz
gcc-68e6d5a6bdd07248e78eccbd19eb282a9531fd7c.tar.bz2
re PR middle-end/81782 (Yet another -Wmaybe-uninitialized false positive with empty array)
2017-12-08 Richard Biener <rguenther@suse.de> PR middle-end/81782 * tree-ssa-uninit.c (warn_uninitialized_vars): Properly handle accesses outside of zero-sized vars. * gcc.dg/uninit-pr81782.c: New testcase. From-SVN: r255512
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr81782.c14
-rw-r--r--gcc/tree-ssa-uninit.c4
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8184c66..bf4dc00 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-08 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81782
+ * tree-ssa-uninit.c (warn_uninitialized_vars): Properly
+ handle accesses outside of zero-sized vars.
+
2017-12-08 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/83141
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d9ce35f..6a68ea6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-08 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81782
+ * gcc.dg/uninit-pr81782.c: New testcase.
+
2017-12-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* g++.dg/opt/pr83252.C: Add -mclear-hwcap on *-*-solaris*.
diff --git a/gcc/testsuite/gcc.dg/uninit-pr81782.c b/gcc/testsuite/gcc.dg/uninit-pr81782.c
new file mode 100644
index 0000000..7d1e902
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr81782.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-Wmaybe-uninitialized" } */
+
+int
+foo (void)
+{
+ char empty_array[] = { };
+ int i, ret = 0;
+
+ for (i = 0; i < (int) (sizeof (empty_array) / sizeof (empty_array[0])); i++)
+ ret = empty_array[i]; /* { dg-bogus "uninitialized" } */
+
+ return ret;
+}
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 4096ded..b17b2b1 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -296,8 +296,8 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
variable. */
if (DECL_P (base)
&& ref.size != -1
- && ref.max_size == ref.size
- && (ref.offset + ref.size <= 0
+ && ((ref.max_size == ref.size
+ && ref.offset + ref.size <= 0)
|| (ref.offset >= 0
&& DECL_SIZE (base)
&& TREE_CODE (DECL_SIZE (base)) == INTEGER_CST