From patchwork Tue Jun 15 13:37:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1492213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jNmPLLL7; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G48Xm5v7qz9t54 for ; Tue, 15 Jun 2021 23:38:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3F913893657 for ; Tue, 15 Jun 2021 13:38:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3F913893657 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623764307; bh=8CHv5D5PtykY4tSh0OoDuMMKRm4Z5K3VbL4UvwCj+a0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jNmPLLL7L/YwfEyeHY/6FPb7QXSA4GAwfVanwdvaap8/M/KnURPBPCFlPlbVHi1z1 3p1lMppOe5LVNWPY47yGqs+Gd3WWlK3sWuWa2avgg5JZwZ1YjMbbVGuiI53WDbKHvE GR6+jsBOifOQ07PQXJnUwcW3JYm+h9yINI2wKPPI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id AAE7C3854809 for ; Tue, 15 Jun 2021 13:38:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AAE7C3854809 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-F12XMLY3N6WsuswmWFKddA-1; Tue, 15 Jun 2021 09:38:04 -0400 X-MC-Unique: F12XMLY3N6WsuswmWFKddA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E04CD1015C8A for ; Tue, 15 Jun 2021 13:38:03 +0000 (UTC) Received: from t14s.localdomain.com (ovpn-112-247.phx2.redhat.com [10.3.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A64C5C1C2; Tue, 15 Jun 2021 13:38:03 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer testsuite: add explode-2a.c [PR101068] Date: Tue, 15 Jun 2021 09:37:58 -0400 Message-Id: <20210615133758.347808-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Due to a bug (PR analyzer/101068), the analyzer only explores a limited subset of the possible paths through gcc.dg/analyzer/explode-2.c, and this artifically helps stop this testcase from exploding. I intend to fix this at some point, but for now, this patch adds a revised test case which captures the effective CFG due to the bug, so that we explicitly have test coverage for that CFG. Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-1479-g954c9235297f2e63acacefd448bc5dabe039ea7c. gcc/testsuite/ChangeLog: PR analyzer/101068 * gcc.dg/analyzer/explode-2a.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/explode-2a.c | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/explode-2a.c diff --git a/gcc/testsuite/gcc.dg/analyzer/explode-2a.c b/gcc/testsuite/gcc.dg/analyzer/explode-2a.c new file mode 100644 index 00000000000..126407f3dd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/explode-2a.c @@ -0,0 +1,51 @@ +/* PR analyzer/101068. */ + +/* { dg-additional-options "--param analyzer-max-enodes-per-program-point=200 --param analyzer-bb-explosion-factor=50" } */ + +#include + +extern int get (void); + +void test (void) +{ + void *p0, *p1, *p2, *p3; + /* Due to not purging constraints on SSA names within loops + (PR analyzer/101068), the analyzer effectively treats the original + explode-2.c as this code. */ + int a = get (); + int b = get (); + while (a) + { + switch (b) + { + default: + case 0: + p0 = malloc (16); /* { dg-warning "leak" } */ + break; + case 1: + free (p0); /* { dg-warning "double-'free' of 'p0'" "" { xfail *-*-* } } */ + break; + + case 2: + p1 = malloc (16); /* { dg-warning "leak" } */ + break; + case 3: + free (p1); /* { dg-warning "double-'free' of 'p1'" "" { xfail *-*-* } } */ + break; + + case 4: + p2 = malloc (16); /* { dg-warning "leak" } */ + break; + case 5: + free (p2); /* { dg-warning "double-'free' of 'p2'" "" { xfail *-*-* } } */ + break; + + case 6: + p3 = malloc (16); /* { dg-warning "leak" } */ + break; + case 7: + free (p3); /* { dg-warning "double-'free' of 'p3'" "" { xfail *-*-* } } */ + break; + } + } +}