diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-02-21 03:12:26 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-02-21 03:12:26 +0000 |
commit | 0cd3142cc55f69acae1568ed9ba80470c6fabe61 (patch) | |
tree | 426e2a074657193977dfd465627f18467dfe9e31 | |
parent | 472b0613ff67e8598ef6a69bb478c721b21a9294 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175715 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Analysis/reinterpret-cast.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/Analysis/reinterpret-cast.cpp b/test/Analysis/reinterpret-cast.cpp index aaa600e4b9..d1aed80a0c 100644 --- a/test/Analysis/reinterpret-cast.cpp +++ b/test/Analysis/reinterpret-cast.cpp @@ -46,3 +46,21 @@ namespace PR14872 { 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}} + } +} |