From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id DBDAE385E007; Thu, 31 Mar 2022 08:35:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBDAE385E007 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7934] tree-optimization/105109 - bogus uninit diagnostic with _Complex X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: bf4832d6fa817f66009f100a9cd68953062add7d X-Git-Newrev: 97ad0b831386e56ecb125a25fff00b2cb0b1a2b9 Message-Id: <20220331083552.DBDAE385E007@sourceware.org> Date: Thu, 31 Mar 2022 08:35:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2022 08:35:53 -0000 https://gcc.gnu.org/g:97ad0b831386e56ecb125a25fff00b2cb0b1a2b9 commit r12-7934-g97ad0b831386e56ecb125a25fff00b2cb0b1a2b9 Author: Richard Biener Date: Thu Mar 31 09:21:27 2022 +0200 tree-optimization/105109 - bogus uninit diagnostic with _Complex When update_address_taken rewrites a _Complex into SSA it changes stores to real/imaginary parts to loads of the other component and a COMPLEX_EXPR. That matches what gimplification does but it misses suppression of diagnostics for the load of the other component. The following patch adds that, syncing up gimplification and update_address_taken behavior. 2022-03-31 Richard Biener PR tree-optimization/105109 * tree-ssa.cc (execute_update_addresses_taken): Suppress diagnostics on the load of the other complex component. * gcc.dg/uninit-pr105109.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/uninit-pr105109.c | 15 +++++++++++++++ gcc/tree-ssa.cc | 1 + 2 files changed, 16 insertions(+) diff --git a/gcc/testsuite/gcc.dg/uninit-pr105109.c b/gcc/testsuite/gcc.dg/uninit-pr105109.c new file mode 100644 index 00000000000..001003ca261 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr105109.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +static void foo(int dim,float _Complex f0[]) +{ + int d; + f0[0] -= 3.14; /* { dg-bogus "uninitialized" } */ + for (d = 0; d < dim; ++d) f0[0] += 3.14; +} +void bar(int dim, const float _Complex u_t[], float _Complex f0[]) +{ + float _Complex exp[1] = {0.}; + foo(dim, exp); + f0[0] = u_t[0] - exp[0]; +} diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc index 6dcb3142869..a362a0a9ea6 100644 --- a/gcc/tree-ssa.cc +++ b/gcc/tree-ssa.cc @@ -1905,6 +1905,7 @@ execute_update_addresses_taken (void) ? REALPART_EXPR : IMAGPART_EXPR, TREE_TYPE (other), TREE_OPERAND (lhs, 0)); + suppress_warning (lrhs); gimple *load = gimple_build_assign (other, lrhs); location_t loc = gimple_location (stmt); gimple_set_location (load, loc);