aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/dynamic-cast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/dynamic-cast.cpp')
-rw-r--r--test/Analysis/dynamic-cast.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp
index 0d0c80fc12..8d1fde8cc5 100644
--- a/test/Analysis/dynamic-cast.cpp
+++ b/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.