analyzer: fix missing bitmap_clear [PR98564]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 02:42:56 +0000 (21:42 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 02:42:56 +0000 (21:42 -0500)
gcc/analyzer/ChangeLog:
PR analyzer/98564
* engine.cc (exploded_path::feasible_p): Add missing call to
bitmap_clear.

gcc/testsuite/ChangeLog:
PR analyzer/98564
* gcc.dg/analyzer/pr98564.c: New test.

gcc/analyzer/engine.cc
gcc/testsuite/gcc.dg/analyzer/pr98564.c [new file with mode: 0644]

index 3ea4524bd653d6bb1a8c4c713e18934c094b2e28..8bc9adf5ee6fc5479710f6dbe38767138af78ca9 100644 (file)
@@ -3374,6 +3374,7 @@ exploded_path::feasible_p (logger *logger, feasibility_problem **out,
   LOG_SCOPE (logger);
 
   auto_sbitmap snodes_visited (eg->get_supergraph ().m_nodes.length ());
+  bitmap_clear (snodes_visited);
 
   /* Traverse the path, updating this model.  */
   region_model model (eng->get_model_manager ());
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98564.c b/gcc/testsuite/gcc.dg/analyzer/pr98564.c
new file mode 100644 (file)
index 0000000..74b1abe
--- /dev/null
@@ -0,0 +1,6 @@
+void *calloc (__SIZE_TYPE__, __SIZE_TYPE__);
+
+void test_1 (void)
+{
+  int *p = calloc (0, 1); /* { dg-message "allocated here" } */
+} /* { dg-warning "leak of 'p'" } */