reinterpret-cast.cpp revision 9f6441ad92c30028032eb3df6f4a7f2ebe393a68
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s 2 3void clang_analyzer_eval(bool); 4 5typedef struct Opaque *Data; 6struct IntWrapper { 7 int x; 8}; 9 10struct Child : public IntWrapper { 11 void set() { x = 42; } 12}; 13 14void test(Data data) { 15 Child *wrapper = reinterpret_cast<Child*>(data); 16 // Don't crash when upcasting here. 17 // We don't actually know if 'data' is a Child. 18 wrapper->set(); 19 clang_analyzer_eval(wrapper->x == 42); // expected-warning{{TRUE}} 20} 21