blob: 9140e1f4a372b02ae76dfaf447e75bd66426f092 [file] [log] [blame]
Dominic Chen184c6242017-03-03 18:02:02 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
2// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s
Anton Yartseve3377fb2013-04-04 23:46:29 +00003
4typedef __typeof(sizeof(int)) size_t;
5void *malloc(size_t);
6void free(void *);
7
8//-------------------------------------------------------------------
Jordan Rose26330562013-04-05 17:55:00 +00009// Check that unix.Malloc + cplusplus.NewDelete does not enable
Anton Yartseve3377fb2013-04-04 23:46:29 +000010// warnings produced by unix.MismatchedDeallocator.
11//-------------------------------------------------------------------
12void testMismatchedDeallocator() {
13 int *p = (int *)malloc(sizeof(int));
14 delete p;
Anna Zaksa1de8562013-04-06 00:41:36 +000015} // expected-warning{{Potential leak of memory pointed to by 'p'}}