From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2209) id 992A43858012; Tue, 15 Jun 2021 13:29:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 992A43858012 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: David Malcolm To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1479] analyzer testsuite: add explode-2a.c [PR101068] X-Act-Checkin: gcc X-Git-Author: David Malcolm X-Git-Refname: refs/heads/master X-Git-Oldrev: ba998f6407ba006a8f8055171ee8e8510f0bc46b X-Git-Newrev: 954c9235297f2e63acacefd448bc5dabe039ea7c Message-Id: <20210615132959.992A43858012@sourceware.org> Date: Tue, 15 Jun 2021 13:29:59 +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: Tue, 15 Jun 2021 13:29:59 -0000 https://gcc.gnu.org/g:954c9235297f2e63acacefd448bc5dabe039ea7c commit r12-1479-g954c9235297f2e63acacefd448bc5dabe039ea7c Author: David Malcolm Date: Tue Jun 15 09:29:23 2021 -0400 analyzer testsuite: add explode-2a.c [PR101068] 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. gcc/testsuite/ChangeLog: PR analyzer/101068 * gcc.dg/analyzer/explode-2a.c: New test. Signed-off-by: David Malcolm Diff: --- gcc/testsuite/gcc.dg/analyzer/explode-2a.c | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) 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; + } + } +}