diff options
author | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
commit | 952eddef9aff85b1e92626e89baaf7a360e2ac85 (patch) | |
tree | df8df0b0067b381eab470a3b8f28d14a552a6340 /test/Analysis/derived-to-base.cpp | |
parent | ea266cad53e3d49771fa38103913d3ec7a166694 (diff) | |
download | FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.zip FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.tar.gz |
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841
Diffstat (limited to 'test/Analysis/derived-to-base.cpp')
-rw-r--r-- | test/Analysis/derived-to-base.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp index 0664189..e9c7ca8 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}} + } +} |