summaryrefslogtreecommitdiffstats
path: root/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp')
-rw-r--r--test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
new file mode 100644
index 0000000..23b70b8
--- /dev/null
+++ b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s
+// expected-no-diagnostics
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+//------------------------------------------------------------------
+// Check that alpha.cplusplus.NewDelete + unix.MismatchedDeallocator
+// does not enable warnings produced by the unix.Malloc checker.
+//------------------------------------------------------------------
+void testMallocFreeNoWarn() {
+ int i;
+ free(&i); // no warn
+
+ int *p1 = (int *)malloc(sizeof(int));
+ free(++p1); // no warn
+
+ int *p2 = (int *)malloc(sizeof(int));
+ free(p2);
+ free(p2); // no warn
+
+ int *p3 = (int *)malloc(sizeof(int)); // no warn
+
+ int *p4 = (int *)malloc(sizeof(int));
+ free(p4);
+ int j = *p4; // no warn
+}
OpenPOWER on IntegriCloud