| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s |
| 2 |
// XFAIL: asserts |
| 3 |
|
| 4 |
void clang_analyzer_eval(bool); |
| 5 |
|
| 6 |
// TODO: The following test will work properly once reinterpret_cast on pointer-to-member is handled properly |
| 7 |
namespace testReinterpretCasting { |
| 8 |
struct Base { |
| 9 |
int field; |
| 10 |
}; |
| 11 |
|
| 12 |
struct Derived : public Base {}; |
| 13 |
|
| 14 |
struct DoubleDerived : public Derived {}; |
| 15 |
|
| 16 |
struct Some {}; |
| 17 |
|
| 18 |
void f() { |
| 19 |
int DoubleDerived::*ddf = &Base::field; |
| 20 |
int Base::*bf = reinterpret_cast<int Base::*>(reinterpret_cast<int Derived::*>(reinterpret_cast<int Base::*>(ddf))); |
| 21 |
int Some::*sf = reinterpret_cast<int Some::*>(ddf); |
| 22 |
Base base; |
| 23 |
base.field = 13; |
| 24 |
clang_analyzer_eval(base.*bf == 13); // expected-warning{{TRUE}} |
| 25 |
} |
| 26 |
} // namespace testReinterpretCasting |