]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/71581 (ICE on valid code on x86_64-linux-gnu with -Wuninit...
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2016 12:46:33 +0000 (14:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2016 12:46:33 +0000 (14:46 +0200)
Backported from mainline
2016-06-20  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/71581
* tree-ssa-uninit.c (warn_uninit): If EXPR and VAR are NULL,
see if T isn't anonymous SSA_NAME with COMPLEX_EXPR created
for conversion of scalar user var to complex type and use the
underlying SSA_NAME_VAR in that case.  If EXPR is still NULL,
punt.

* gcc.dg/pr71581.c: New test.

From-SVN: r238099

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

index c4ee0ef9ed1a5d5398c97e79b58acb88b38c5a92..27ba5b37f8310af99c503055a1c6369eb3657cfc 100644 (file)
@@ -1,6 +1,15 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-06-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71581
+       * tree-ssa-uninit.c (warn_uninit): If EXPR and VAR are NULL,
+       see if T isn't anonymous SSA_NAME with COMPLEX_EXPR created
+       for conversion of scalar user var to complex type and use the
+       underlying SSA_NAME_VAR in that case.  If EXPR is still NULL,
+       punt.
+
        2016-06-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/71494
index ed6444ef157edb14440243209b5c09a7cb5795df..579c7245d76e40c67616d9b96b2c223bdc5ee715 100644 (file)
@@ -1,6 +1,11 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-06-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71581
+       * gcc.dg/pr71581.c: New test.
+
        2016-06-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/71528
diff --git a/gcc/testsuite/gcc.dg/pr71581.c b/gcc/testsuite/gcc.dg/pr71581.c
new file mode 100644 (file)
index 0000000..d82eb1e
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR middle-end/71581 */
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+_Complex float
+f1 (void)
+{
+  float x;
+  return x;    /* { dg-warning "is used uninitialized in this function" } */
+}
+
+_Complex double
+f2 (void)
+{
+  double x;
+  return x;    /* { dg-warning "is used uninitialized in this function" } */
+}
+
+_Complex int
+f3 (void)
+{
+  int x;
+  return x;    /* { dg-warning "is used uninitialized in this function" } */
+}
index 96f1aaf3e541fe7877446c05a39af5bb13a7a247..2d9ac297db237e0bb87b5f43d4763e3e0c11af9e 100644 (file)
@@ -159,6 +159,31 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
   if (!has_undefined_value_p (t))
     return;
 
+  /* Anonymous SSA_NAMEs shouldn't be uninitialized, but ssa_undefined_value_p
+     can return true if the def stmt of anonymous SSA_NAME is COMPLEX_EXPR
+     created for conversion from scalar to complex.  Use the underlying var of
+     the COMPLEX_EXPRs real part in that case.  See PR71581.  */
+  if (expr == NULL_TREE
+      && var == NULL_TREE
+      && SSA_NAME_VAR (t) == NULL_TREE
+      && is_gimple_assign (SSA_NAME_DEF_STMT (t))
+      && gimple_assign_rhs_code (SSA_NAME_DEF_STMT (t)) == COMPLEX_EXPR)
+    {
+      tree v = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (t));
+      if (TREE_CODE (v) == SSA_NAME
+         && has_undefined_value_p (v)
+         && (integer_zerop (gimple_assign_rhs2 (SSA_NAME_DEF_STMT (t)))
+             || real_zerop (gimple_assign_rhs2 (SSA_NAME_DEF_STMT (t)))
+             || fixed_zerop (gimple_assign_rhs2 (SSA_NAME_DEF_STMT (t)))))
+       {
+         expr = SSA_NAME_VAR (v);
+         var = expr;
+       }
+    }
+
+  if (expr == NULL_TREE)
+    return;
+
   /* TREE_NO_WARNING either means we already warned, or the front end
      wishes to suppress the warning.  */
   if ((context