From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 6C3DF3858404 for ; Fri, 26 Aug 2022 10:58:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C3DF3858404 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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-out2.suse.de (Postfix) with ESMTPS id 787CA1FDBD for ; Fri, 26 Aug 2022 10:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661511514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jnAVANwdyJ1kL/0xpcRvW5bILGx8jPKVzTARsKMp1Fk=; b=1Biw1TzWblRNl2d3/cgL1avwCmggm4n5Q1Xl1FQ7K800fcjgx8bEzhdGc7sfYaiZmqDC8F 6I1oeIb4UzPEh2/1xoTVvrcUDJy0HpjX3dpS+5Q4hazP6ewdngCDxl810WQMGgJZLBBsyO MmB55r5i5O6lq87ejXyASx3h3YkE4kA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661511514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jnAVANwdyJ1kL/0xpcRvW5bILGx8jPKVzTARsKMp1Fk=; b=5L6gAZfb/uDk0B6DzPf57CXoPznh3aPSahvU8pthj4oK+w6f+p9LxAYqdwfT/F1CNbcHYD WkM4lifuP/+fn3DQ== 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 675CD13A7E for ; Fri, 26 Aug 2022 10:58:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SEE+GFqnCGMmaQAAMHmgww (envelope-from ) for ; Fri, 26 Aug 2022 10:58:34 +0000 Date: Fri, 26 Aug 2022 12:58:34 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] New testcase for uninit MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220826105834.675CD13A7E@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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The following adds a testcase that illustrates a defect in compute_control_dep_chain and its attempt to identify loop exits as special to continue walking post-dominators but failing to do so for following post-dominators. On trunk there is now simple_control_dep_chain saving the day, avoiding the false positive but with GCC 12 we get a bogus diagnostic. Pushed. * gcc.dg/uninit-pred-11.c: New testcase. --- gcc/testsuite/gcc.dg/uninit-pred-11.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-pred-11.c diff --git a/gcc/testsuite/gcc.dg/uninit-pred-11.c b/gcc/testsuite/gcc.dg/uninit-pred-11.c new file mode 100644 index 00000000000..734df379ef7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pred-11.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); +int z; +unsigned foo (unsigned v, int y) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + // This variation from uninit-25.c causes compute_control_dep_chain + // to run into a defect but simple_control_dep_chain saves us here + if (y) + z = 1; + if (v != 1) + return u; /* { dg-bogus "may be used uninitialized" } */ + + return 0; +} -- 2.35.3