summaryrefslogtreecommitdiff
path: root/test/Analysis/derived-to-base.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
commitbfef399519ca9b8a4b4c6b563253bad7e0eeffe0 (patch)
treedf8df0b0067b381eab470a3b8f28d14a552a6340 /test/Analysis/derived-to-base.cpp
parent6a0372513edbc473b538d2f724efac50405d6fef (diff)
Diffstat (limited to 'test/Analysis/derived-to-base.cpp')
-rw-r--r--test/Analysis/derived-to-base.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp
index 0664189a9564..e9c7ca8f731f 100644
--- a/test/Analysis/derived-to-base.cpp
+++ b/test/Analysis/derived-to-base.cpp
@@ -450,3 +450,28 @@ namespace PR15394 {
}
};
+namespace Bug16309 {
+ struct Incomplete;
+
+ struct Base { virtual ~Base(); };
+
+ struct Derived : public Base { int x; };
+
+ void* f(Incomplete *i) {
+ Base *b = reinterpret_cast<Base *>(i);
+ // This used to crash because of the reinterpret_cast above.
+ Derived *d = dynamic_cast<Derived *>(b);
+ return d;
+ }
+
+ // And check that reinterpret+dynamic casts work correctly after the fix.
+ void g() {
+ Derived d;
+ d.x = 47;
+ Base *b = &d;
+ Incomplete *i = reinterpret_cast<Incomplete *>(b);
+ Base *b2 = reinterpret_cast<Base *>(i);
+ Derived *d2 = dynamic_cast<Derived *>(b2);
+ clang_analyzer_eval(d2->x == 47); // expected-warning{{TRUE}}
+ }
+}