diff options
Diffstat (limited to 'test/Analysis/new-fail.cpp')
-rw-r--r-- | test/Analysis/new-fail.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Analysis/new-fail.cpp b/test/Analysis/new-fail.cpp new file mode 100644 index 0000000000..8b1903fbea --- /dev/null +++ b/test/Analysis/new-fail.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store region -verify %s +// XFAIL: * + +void f1() { + int *n = new int; + if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}} + } +} + +void f2() { + int *n = new int(3); + if (*n) { // no-warning + } +} + +void *operator new(size_t, void *, void *); +void *testCustomNew() { + int *x = (int *)malloc(sizeof(int)); + void *y = new (0, x) int; + return y; // no-warning (placement new could have freed x) +} |