]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/40943 (Uninitialized warning is missed when dereferencing uninitiali...
authorJakub Jelinek <jakub@redhat.com>
Mon, 3 Aug 2009 19:26:10 +0000 (21:26 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 3 Aug 2009 19:26:10 +0000 (21:26 +0200)
PR middle-end/40943
* tree-ssa.c (warn_uninitialized_var): Even on LHS warn for
operand of INDIRECT_REF.

* gcc.dg/uninit-6.c: Re-add XFAIL.
* gcc.dg/uninit-6-O0.c: Likewise.
* gcc.dg/uninit-pr40943.c: New test.

From-SVN: r150379

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

index 04816e3f0de9fd7d6a9697474c3fbb3d710a1fd8..4d9d516f3edaefde3048296a07e27c5d7fdf1fd3 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/40943
+       * tree-ssa.c (warn_uninitialized_var): Even on LHS warn for
+       operand of INDIRECT_REF.
+
 2009-08-03  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/alpha.c (alpha_legitimate_constant_p): Reject CONST
index 26560b505fe29edbc6488d6a2b58498b8c5f3987..e2b141cfd30d6ee77407ae1ffb2175ee48d0d456 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/40943
+       * gcc.dg/uninit-6.c: Re-add XFAIL.
+       * gcc.dg/uninit-6-O0.c: Likewise.
+       * gcc.dg/uninit-pr40943.c: New test.
+
 2009-08-03  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR testsuite/40858
index f4588305ffa3aaf6b578b4bfd57cfaf3b981e78c..e3fefe5e1c5ac154fd3fe53a7a361dec2700e49d 100644 (file)
@@ -39,7 +39,7 @@ make_something(int a, int b, int c)
     rv = malloc (sizeof (struct tree));
     rv->car = 0;
 
-    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" } */
+    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */
     APPEND(rv, field, PTR_T, b);
     APPEND(rv, field, INTEGER_T, c);
 
index 009e124fccf8972f22ba720224f7400f22f85c89..b0f2083ab4b8676e128c6f85a7ecfd4b8d0ae779 100644 (file)
@@ -39,7 +39,7 @@ make_something(int a, int b, int c)
     rv = malloc (sizeof (struct tree));
     rv->car = 0;
 
-    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" } */
+    APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */
     APPEND(rv, field, PTR_T, b);
     APPEND(rv, field, INTEGER_T, c);
 
diff --git a/gcc/testsuite/gcc.dg/uninit-pr40943.c b/gcc/testsuite/gcc.dg/uninit-pr40943.c
new file mode 100644 (file)
index 0000000..2b6e913
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR middle-end/40943 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+void
+foo (void)
+{
+  int *p;
+  *p = 3;      /* { dg-warning "is used uninitialized" } */
+}
index 504491040b4bb1c5134038b79ed398addd8e7e9c..28da94bb21cacd309aa77793c7d9bdcb2038a75c 100644 (file)
@@ -1265,7 +1265,12 @@ warn_uninitialized_var (tree *tp, int *walk_subtrees, void *data_)
 
   /* We do not care about LHS.  */
   if (wi->is_lhs)
-    return NULL_TREE;
+    {
+      /* Except for operands of INDIRECT_REF.  */
+      if (!INDIRECT_REF_P (t))
+       return NULL_TREE;
+      t = TREE_OPERAND (t, 0);
+    }
 
   switch (TREE_CODE (t))
     {