Jordan Rose | e449edc | 2013-04-05 17:55:07 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s |
| 2 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -verify %s |
Anton Yartsev | 648cb71 | 2013-04-04 23:46:29 +0000 | [diff] [blame] | 3 | |
| 4 | typedef __typeof(sizeof(int)) size_t; |
| 5 | void *malloc(size_t); |
| 6 | void free(void *); |
| 7 | |
| 8 | //------------------------------------------------------------------- |
Jordan Rose | e85deb3 | 2013-04-05 17:55:00 +0000 | [diff] [blame] | 9 | // Check that unix.Malloc + cplusplus.NewDelete does not enable |
Anton Yartsev | 648cb71 | 2013-04-04 23:46:29 +0000 | [diff] [blame] | 10 | // warnings produced by unix.MismatchedDeallocator. |
| 11 | //------------------------------------------------------------------- |
| 12 | void testMismatchedDeallocator() { |
| 13 | int *p = (int *)malloc(sizeof(int)); |
| 14 | delete p; |
Anna Zaks | 68eb4c2 | 2013-04-06 00:41:36 +0000 | [diff] [blame^] | 15 | } // expected-warning{{Potential leak of memory pointed to by 'p'}} |