1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s 2 3 // rdar://problem/64202361 4 5 struct A { 6 int a; 7 struct { 8 struct { 9 int b; 10 union { 11 int c; 12 }; 13 }; 14 }; 15 }; 16 17 int testCrash() { 18 int *x = 0; 19 int A::*ap = &A::a; 20 21 if (ap) // no crash 22 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 23 24 return 10; 25 } 26 27 int testIndirectCrash() { 28 int *x = 0; 29 int A::*cp = &A::c; 30 31 if (cp) // no crash 32 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 33 34 return 10; 35 } 36 37 // PR46264 38 // This case shall not crash with an assertion failure about void* dereferening. 39 namespace ns1 { 40 namespace a { 41 class b { 42 public: 43 typedef int b::*c; 44 operator c() { return d ? &b::d : 0; } 45 int d; 46 }; 47 } // namespace a 48 using a::b; 49 class e { 50 void f(); 51 void g(); 52 b h; 53 }; 54 void e::f() { 55 e *i; 56 if (h) 57 i->g(); // expected-warning{{Called C++ object pointer is uninitialized}} 58 } 59 } // namespace ns1 60