PR middle-end/23497
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Nov 2005 23:43:39 +0000 (23:43 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Nov 2005 23:43:39 +0000 (23:43 +0000)
        * tree-ssa.c (warn_uninitialized_var): Skip real and imaginary
        parts of an SSA_NAME.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107107 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 5c7ce8e..f0555b3 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-16  Richard Henderson  <rth@redhat.com>
+
+       PR middle-end/23497
+       * tree-ssa.c (warn_uninitialized_var): Skip real and imaginary
+       parts of an SSA_NAME.
+
 2005-11-16  Richard Earnshaw  <richard.earnshaw@arm.com>
 
        PR target/24861
diff --git a/gcc/testsuite/gcc.dg/uninit-12.c b/gcc/testsuite/gcc.dg/uninit-12.c
new file mode 100644 (file)
index 0000000..7889e53
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR 23497 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+typedef _Complex float C;
+C foo()
+{
+  C f;
+  __real__ f = 0;
+  __imag__ f = 0;
+  return f;
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-13.c b/gcc/testsuite/gcc.dg/uninit-13.c
new file mode 100644 (file)
index 0000000..168939a
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+typedef _Complex float C;
+C foo()
+{
+  C f;
+  __imag__ f = 0;
+  return f;            /* { dg-warning "" "uninit" { xfail *-*-* } } */
+}
index 081d21a..7b24c59 100644 (file)
@@ -1155,14 +1155,29 @@ warn_uninitialized_var (tree *tp, int *walk_subtrees, void *data)
 {
   tree t = *tp;
 
-  /* We only do data flow with SSA_NAMEs, so that's all we can warn about.  */
-  if (TREE_CODE (t) == SSA_NAME)
+  switch (TREE_CODE (t))
     {
+    case SSA_NAME:
+      /* We only do data flow with SSA_NAMEs, so that's all we
+        can warn about.  */
       warn_uninit (t, "%H%qD is used uninitialized in this function", data);
       *walk_subtrees = 0;
+      break;
+
+    case REALPART_EXPR:
+    case IMAGPART_EXPR:
+      /* The total store transformation performed during gimplification
+        creates uninitialized variable uses.  If all is well, these will
+        be optimized away, so don't warn now.  */
+      if (TREE_CODE (TREE_OPERAND (t, 0)) == SSA_NAME)
+       *walk_subtrees = 0;
+      break;
+
+    default:
+      if (IS_TYPE_OR_DECL_P (t))
+       *walk_subtrees = 0;
+      break;
     }
-  else if (IS_TYPE_OR_DECL_P (t))
-    *walk_subtrees = 0;
 
   return NULL_TREE;
 }