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