[analyzer] Add another reinterpret_cast behavior test.
The test is similar to <rdar://problem/13239840> but doesn't actually test
the case that fails there. It's still a good test, though.
llvm-svn: 175715
diff --git a/clang/test/Analysis/reinterpret-cast.cpp b/clang/test/Analysis/reinterpret-cast.cpp
index aaa600e..d1aed80 100644
--- a/clang/test/Analysis/reinterpret-cast.cpp
+++ b/clang/test/Analysis/reinterpret-cast.cpp
@@ -46,3 +46,21 @@
f2(p);
}
}
+
+namespace rdar13249297 {
+ struct IntWrapperSubclass : public IntWrapper {};
+
+ struct IntWrapperWrapper {
+ IntWrapper w;
+ };
+
+ void test(IntWrapperWrapper *ww) {
+ reinterpret_cast<IntWrapperSubclass *>(ww)->x = 42;
+ clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass *>(ww)->x == 42); // expected-warning{{TRUE}}
+
+ clang_analyzer_eval(ww->w.x == 42); // expected-warning{{TRUE}}
+ ww->w.x = 0;
+
+ clang_analyzer_eval(reinterpret_cast<IntWrapperSubclass *>(ww)->x == 42); // expected-warning{{FALSE}}
+ }
+}