From patchwork Thu Mar 31 08:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 52499 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31E7B385741C for ; Thu, 31 Mar 2022 08:36:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31E7B385741C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648715770; bh=0KAaJmxLze8pxZUBsQarOeGmGPP7vozLBnka5xRjG04=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tZ7ntOm1CKzEPdHVM7rZTzUjI39emDETR6L2y2iip+es0iHHIUO/d6F6GxQOYTRI6 veLRKFXFKGFqgvXy3DrQaLkp0hsgVPvC3y6tEM4kuE0gRm2ENnUUILl1NZg32BNfZ0 oyDoNsEQXWW/YwLeX32V8M3mbiYLTRMP1NWvf1qc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 1FB943858C50 for ; Thu, 31 Mar 2022 08:35:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1FB943858C50 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1410D21A90 for ; Thu, 31 Mar 2022 08:35:36 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 013CD133D4 for ; Thu, 31 Mar 2022 08:35:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t664OtdnRWJvHwAAMHmgww (envelope-from ) for ; Thu, 31 Mar 2022 08:35:35 +0000 Date: Thu, 31 Mar 2022 10:35:35 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105109 - bogus uninit diagnostic with _Complex MIME-Version: 1.0 Message-Id: <20220331083536.013CD133D4@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 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. --- gcc/testsuite/gcc.dg/uninit-pr105109.c | 15 +++++++++++++++ gcc/tree-ssa.cc | 1 + 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-pr105109.c 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);