public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1479] analyzer testsuite: add explode-2a.c [PR101068]
@ 2021-06-15 13:29 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2021-06-15 13:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:954c9235297f2e63acacefd448bc5dabe039ea7c

commit r12-1479-g954c9235297f2e63acacefd448bc5dabe039ea7c
Author: David Malcolm <dmalcolm@redhat.com>
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 <dmalcolm@redhat.com>

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 <stdlib.h>
+
+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;
+	}
+    }
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-15 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 13:29 [gcc r12-1479] analyzer testsuite: add explode-2a.c [PR101068] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).