diff options
author | dim <dim@FreeBSD.org> | 2012-08-19 10:33:04 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-19 10:33:04 +0000 |
commit | cc73504950eb7b5dff2dded9bedd67bc36d64641 (patch) | |
tree | 5b9c2fa9d79942fbdce3d618e37e27c18263af9a /test/Analysis/reinterpret-cast.cpp | |
parent | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (diff) | |
download | FreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.zip FreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.tar.gz |
Vendor import of clang trunk r162107:
http://llvm.org/svn/llvm-project/cfe/trunk@162107
Diffstat (limited to 'test/Analysis/reinterpret-cast.cpp')
-rw-r--r-- | test/Analysis/reinterpret-cast.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Analysis/reinterpret-cast.cpp b/test/Analysis/reinterpret-cast.cpp new file mode 100644 index 0000000..73f2e2d --- /dev/null +++ b/test/Analysis/reinterpret-cast.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s + +void clang_analyzer_eval(bool); + +typedef struct Opaque *Data; +struct IntWrapper { + int x; +}; + +struct Child : public IntWrapper { + void set() { x = 42; } +}; + +void test(Data data) { + Child *wrapper = reinterpret_cast<Child*>(data); + // Don't crash when upcasting here. + // We don't actually know if 'data' is a Child. + wrapper->set(); + clang_analyzer_eval(wrapper->x == 42); // expected-warning{{TRUE}} +} |