From d7f45b87956421635fe872aced86bf24e7b74af8 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 20 Jun 2016 21:41:20 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237621 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr71581.c | 24 ++++++++++++++++++++++++ gcc/tree-ssa-uninit.c | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr71581.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4b3aae5d6d..1f47a9d9bef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2016-06-20 Jakub Jelinek + 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. + PR rtl-optimization/71591 * toplev.c (toplev::run_self_tests): If no_backend, complain and don't run any tests. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b966e956bc..ce31fb71f5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-06-20 Jakub Jelinek + PR middle-end/71581 + * gcc.dg/pr71581.c: New test. + PR rtl-optimization/71591 * gcc.dg/cpp/pr71591.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr71581.c b/gcc/testsuite/gcc.dg/pr71581.c new file mode 100644 index 00000000000..d82eb1ed5c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71581.c @@ -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" } */ +} diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 941d575f848..d5f03442c3d 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -131,6 +131,29 @@ 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) + && 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 -- 2.11.4.GIT