diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-12.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-13.c | 10 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 23 |
4 files changed, 47 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c7ce8e..f0555b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 index 0000000..7889e53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-12.c @@ -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 index 0000000..168939a --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-13.c @@ -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 *-*-* } } */ +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 081d21a..7b24c59 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -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; } |