1 // RUN: %clang_analyze_cc1 -std=c++11 -verify %s \
2 // RUN:   -analyzer-checker=core \
3 // RUN:   -analyzer-checker=cplusplus.NewDelete \
4 // RUN:   -analyzer-checker=unix.MismatchedDeallocator
5 //
6 // RUN: %clang_analyze_cc1 -std=c++11 -verify %s \
7 // RUN:   -analyzer-checker=core \
8 // RUN:   -analyzer-checker=cplusplus.NewDelete \
9 // RUN:   -analyzer-checker=cplusplus.NewDeleteLeaks \
10 // RUN:   -analyzer-checker=unix.MismatchedDeallocator
11 
12 // expected-no-diagnostics
13 
14 typedef __typeof(sizeof(int)) size_t;
15 void *malloc(size_t);
16 void free(void *);
17 
18 //------------------------------------------------------------------
19 // Check that alpha.cplusplus.NewDelete + unix.MismatchedDeallocator
20 // does not enable warnings produced by the unix.Malloc checker.
21 //------------------------------------------------------------------
testMallocFreeNoWarn()22 void testMallocFreeNoWarn() {
23   int i;
24   free(&i); // no warn
25 
26   int *p1 = (int *)malloc(sizeof(int));
27   free(++p1); // no warn
28 
29   int *p2 = (int *)malloc(sizeof(int));
30   free(p2);
31   free(p2); // no warn
32 
33   int *p3 = (int *)malloc(sizeof(int)); // no warn
34 
35   int *p4 = (int *)malloc(sizeof(int));
36   free(p4);
37   int j = *p4; // no warn
38 }
39