From d07f8c591acf1ed2f99873464093b8729a8da0f2 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 11 Nov 2016 12:53:36 +0000 Subject: [PATCH] re PR middle-end/78295 (Spurious -Wuninitialized warning for vector element assignment) 2016-11-11 Richard Biener PR middle-end/78295 * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn about uninitialized destination arg of BIT_INSERT_EXPR. * gcc.dg/uninit-pr78295.c: New testcase. From-SVN: r242068 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/uninit-pr78295.c | 13 +++++++++++++ gcc/tree-ssa-uninit.c | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-pr78295.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5cbc53d45b7..5ca356d7b13 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-11 Richard Biener + + PR middle-end/78295 + * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn + about uninitialized destination arg of BIT_INSERT_EXPR. + 2016-11-10 Sandra Loosemore PR c/37998 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e16fdde8db9..acec6d95343 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-11 Richard Biener + + PR middle-end/78295 + * gcc.dg/uninit-pr78295.c: New testcase. + 2016-11-10 Fritz O. Reese PR fortran/78277 diff --git a/gcc/testsuite/gcc.dg/uninit-pr78295.c b/gcc/testsuite/gcc.dg/uninit-pr78295.c new file mode 100644 index 00000000000..ae0b21469b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr78295.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +typedef double vectype __attribute__ ((__vector_size__ (16))); + +vectype +f (double x) +{ + vectype t; + for (int i = 0; i < 2; i++) + t[i] = x; /* { dg-bogus "uninitialized" } */ + return t; +} diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 13448548e0e..dfee0ea72d1 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -212,6 +212,14 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) can warn about. */ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, op_iter, SSA_OP_USE) { + /* BIT_INSERT_EXPR first operand should not be considered + a use for the purpose of uninit warnings. */ + if (gassign *ass = dyn_cast (stmt)) + { + if (gimple_assign_rhs_code (ass) == BIT_INSERT_EXPR + && use_p->use == gimple_assign_rhs1_ptr (ass)) + continue; + } use = USE_FROM_PTR (use_p); if (always_executed) warn_uninit (OPT_Wuninitialized, use, SSA_NAME_VAR (use), -- 2.30.2