re PR tree-optimization/79955 (GLIBC build fails after r245840)
authorRichard Biener <rguenther@suse.de>
Wed, 8 Mar 2017 14:10:47 +0000 (14:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 8 Mar 2017 14:10:47 +0000 (14:10 +0000)
2017-03-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79955
* tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn
for accesses that are completely outside of the variable.

* gcc.dg/uninit-24.c: New testcase.

From-SVN: r245976

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/uninit-24.c [new file with mode: 0644]
gcc/tree-ssa-uninit.c

index 56b228122770cce073ae75a98d335eb9393c6962..c59224eab3903c96d355c0021ff290720c4624fa 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79955
+       * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn
+       for accesses that are completely outside of the variable.
+
 2017-03-08  Andrew Haley  <aph@redhat.com>
 
        PR tree-optimization/79943
index 5824caf414bd896e76ca270f71f7e459a638d6fa..396ab3ad1218c104b1efa1b6ace29c91d35bfa59 100644 (file)
@@ -7,6 +7,11 @@
        PR tree-optimization/79943
        * gcc.dg/tree-ssa/pr79943.c: New test.
 
+2017-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79955
+       * gcc.dg/uninit-24.c: New testcase.
+
 2017-03-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/79920
diff --git a/gcc/testsuite/gcc.dg/uninit-24.c b/gcc/testsuite/gcc.dg/uninit-24.c
new file mode 100644 (file)
index 0000000..30fe1e5
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wmaybe-uninitialized" } */
+
+int foo (int x)
+{
+  int y;
+  if (x)
+    return *(&y + 1); /* { dg-bogus "may be used uninitialized" } */
+  return 0;
+}
index 1805c674ea497b31123b4e27aa2708369ad0c7cb..e019ecc9d29e019af64fdf2b077fb7b4c80fb4a1 100644 (file)
@@ -287,6 +287,17 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
                  || TREE_NO_WARNING (base))
                continue;
 
+             /* Do not warn if the access is fully outside of the
+                variable.  */
+             if (ref.size != -1
+                 && ref.max_size == ref.size
+                 && (ref.offset + ref.size <= 0
+                     || (ref.offset >= 0
+                         && TREE_CODE (DECL_SIZE (base)) == INTEGER_CST
+                         && compare_tree_int (DECL_SIZE (base),
+                                              ref.offset) <= 0)))
+               continue;
+
              /* Limit the walking to a constant number of stmts after
                 we overcommit quadratic behavior for small functions
                 and O(n) behavior.  */