diff options
Diffstat (limited to 'clang/test/Analysis/dynamic-cast.cpp')
-rw-r--r-- | clang/test/Analysis/dynamic-cast.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/test/Analysis/dynamic-cast.cpp b/clang/test/Analysis/dynamic-cast.cpp index 0d0c80fc120..8d1fde8cc5c 100644 --- a/clang/test/Analysis/dynamic-cast.cpp +++ b/clang/test/Analysis/dynamic-cast.cpp @@ -167,10 +167,18 @@ int testCastToVoidStar() { return *res; // no warning } -int testReference() { +int testReferenceSuccesfulCast() { + B rb; + B &b = dynamic_cast<B&>(rb); + int *x = 0; + return *x; // expected-warning {{Dereference of null pointer}} +} + +int testReferenceFailedCast() { A a; B &b = dynamic_cast<B&>(a); - return b.m; // no warning + int *x = 0; + return *x; // no warning (An exception is thrown by the cast.) } // False negatives. |