re PR middle-end/23497 (Bogus 'is used uninitialized...' warning about std::complex<T>)

PR middle-end/23497
        * tree-ssa.c (warn_uninitialized_var): Skip real and imaginary
        parts of an SSA_NAME.

From-SVN: r107107
This commit is contained in:
Richard Henderson 2005-11-16 15:43:39 -08:00 committed by Richard Henderson
parent dbb28e4b13
commit 978dee9ad2
4 changed files with 47 additions and 4 deletions

View 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

View File

@ -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;
}

View File

@ -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 *-*-* } } */
}

View 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;
}