From: Jordan Rose Date: Thu, 21 Feb 2013 03:12:26 +0000 (+0000) Subject: [analyzer] Add another reinterpret_cast behavior test. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0cd3142cc55f69acae1568ed9ba80470c6fabe61;p=clang [analyzer] Add another reinterpret_cast behavior test. The test is similar to 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 --- 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(ww)->x = 42; + clang_analyzer_eval(reinterpret_cast(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(ww)->x == 42); // expected-warning{{FALSE}} + } +}