]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/89296 (tree copy-header masking uninitialized warning)
authorRichard Biener <rguenther@suse.de>
Mon, 18 Feb 2019 12:56:15 +0000 (12:56 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 18 Feb 2019 12:56:15 +0000 (12:56 +0000)
2019-02-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89296
* tree-ssa-loop-ch.c (ch_base::copy_headers): Restrict setting
of no-warning flag to cases that might emit the bogus warning.

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

From-SVN: r268986

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

index 553f0189f768cddd232e43970a823511f272d3a3..bf74a0af23438dc3063d0b9e9bb0b604b96f9415 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89296
+       * tree-ssa-loop-ch.c (ch_base::copy_headers): Restrict setting
+       of no-warning flag to cases that might emit the bogus warning.
+
 2019-02-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/88714
index 2ca40b00dabc3893ac14f365c614d86a945a3139..2a68cf239218a35eea71d563d6ac028264ca86b8 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89296
+       * gcc.dg/uninit-pr89296.c: New testcase.
+
 2019-02-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/89369
diff --git a/gcc/testsuite/gcc.dg/uninit-pr89296.c b/gcc/testsuite/gcc.dg/uninit-pr89296.c
new file mode 100644 (file)
index 0000000..9d81b32
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+int get_a_value ();
+void printk(const char *);
+void test_func()
+{
+    int loop;
+    while (!loop) {             /* { dg-warning "is used uninitialized" } */
+       loop = get_a_value();
+       printk("...");
+    }
+}
index 1b8cb82cfd8c5e8621e0125c8eb56b2289645a41..f65e2b505675153295702e01366a90e04ef4087e 100644 (file)
@@ -452,11 +452,23 @@ ch_base::copy_headers (function *fun)
                {
                  gimple *stmt = gsi_stmt (bsi);
                  if (gimple_code (stmt) == GIMPLE_COND)
-                   gimple_set_no_warning (stmt, true);
+                   {
+                     tree lhs = gimple_cond_lhs (stmt);
+                     if (gimple_cond_code (stmt) != EQ_EXPR
+                         && gimple_cond_code (stmt) != NE_EXPR
+                         && INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+                         && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (lhs)))
+                       gimple_set_no_warning (stmt, true);
+                   }
                  else if (is_gimple_assign (stmt))
                    {
                      enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
-                     if (TREE_CODE_CLASS (rhs_code) == tcc_comparison)
+                     tree rhs1 = gimple_assign_rhs1 (stmt);
+                     if (TREE_CODE_CLASS (rhs_code) == tcc_comparison
+                         && rhs_code != EQ_EXPR
+                         && rhs_code != NE_EXPR
+                         && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+                         && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (rhs1)))
                        gimple_set_no_warning (stmt, true);
                    }
                }