Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / NewDelete+MismatchedDeallocator_intersections.cpp
blob4d84c8b614a520ea1e97438975de669e212fd94e
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
12 // expected-no-diagnostics
14 typedef __typeof(sizeof(int)) size_t;
15 void *malloc(size_t);
16 void free(void *);
18 //------------------------------------------------------------------
19 // Check that alpha.cplusplus.NewDelete + unix.MismatchedDeallocator
20 // does not enable warnings produced by the unix.Malloc checker.
21 //------------------------------------------------------------------
22 void testMallocFreeNoWarn() {
23 int i;
24 free(&i); // no warn
26 int *p1 = (int *)malloc(sizeof(int));
27 free(++p1); // no warn
29 int *p2 = (int *)malloc(sizeof(int));
30 free(p2);
31 free(p2); // no warn
33 int *p3 = (int *)malloc(sizeof(int)); // no warn
35 int *p4 = (int *)malloc(sizeof(int));
36 free(p4);
37 int j = *p4; // no warn