diff options
author | dim <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
commit | 50b73317314e889cf39c7b1d6cbf419fa7502f22 (patch) | |
tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /test/Analysis/nullptr.cpp | |
parent | dc04cb328508e61aad809d9b53b12f9799a00e7d (diff) | |
download | FreeBSD-src-50b73317314e889cf39c7b1d6cbf419fa7502f22.zip FreeBSD-src-50b73317314e889cf39c7b1d6cbf419fa7502f22.tar.gz |
Vendor import of clang trunk r154661:
http://llvm.org/svn/llvm-project/cfe/trunk@r154661
Diffstat (limited to 'test/Analysis/nullptr.cpp')
-rw-r--r-- | test/Analysis/nullptr.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index fc7e7ef..3119b4f 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core -analyzer-store region -verify %s +// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s // test to see if nullptr is detected as a null pointer void foo1(void) { @@ -39,7 +39,6 @@ void foo4(void) { *np = 0; // no-warning } - int pr10372(void *& x) { // GNU null is a pointer-sized integer, not a pointer. x = __null; @@ -47,3 +46,38 @@ int pr10372(void *& x) { return __null; } +void zoo1() { + char **p = 0; + delete *(p + 0); // expected-warning{{Dereference of null pointer}} +} + +void zoo2() { + int **a = 0; + int **b = 0; + asm ("nop" + :"=a"(*a) + :"0"(*b) // expected-warning{{Dereference of null pointer}} + ); +} + +int exprWithCleanups() { + struct S { + S(int a):a(a){} + ~S() {} + + int a; + }; + + int *x = 0; + return S(*x).a; // expected-warning{{Dereference of null pointer}} +} + +int materializeTempExpr() { + int *n = 0; + struct S { + int a; + S(int i): a(i) {} + }; + const S &s = S(*n); // expected-warning{{Dereference of null pointer}} + return s.a; +} |