2013-04-06 01:55:07 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
|
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -verify %s
|
2013-04-05 07:46:29 +08:00
|
|
|
|
|
|
|
typedef __typeof(sizeof(int)) size_t;
|
|
|
|
void *malloc(size_t);
|
|
|
|
void free(void *);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
2013-04-06 01:55:00 +08:00
|
|
|
// Check that unix.Malloc + cplusplus.NewDelete does not enable
|
2013-04-05 07:46:29 +08:00
|
|
|
// warnings produced by unix.MismatchedDeallocator.
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void testMismatchedDeallocator() {
|
|
|
|
int *p = (int *)malloc(sizeof(int));
|
|
|
|
delete p;
|
2013-04-06 08:41:36 +08:00
|
|
|
} // expected-warning{{Potential leak of memory pointed to by 'p'}}
|