Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / PR46264.cpp
blob7a5c4d282e123d0f79d13e30ef1c0f8bc05304fa
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
3 struct A {
4 int a;
5 struct {
6 struct {
7 int b;
8 union {
9 int c;
15 int testCrash() {
16 int *x = 0;
17 int A::*ap = &A::a;
19 if (ap) // no crash
20 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
22 return 10;
25 int testIndirectCrash() {
26 int *x = 0;
27 int A::*cp = &A::c;
29 if (cp) // no crash
30 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
32 return 10;
35 // PR46264
36 // This case shall not crash with an assertion failure about void* dereferening.
37 namespace ns1 {
38 namespace a {
39 class b {
40 public:
41 typedef int b::*c;
42 operator c() { return d ? &b::d : 0; }
43 int d;
45 } // namespace a
46 using a::b;
47 class e {
48 void f();
49 void g();
50 b h;
52 void e::f() {
53 e *i;
54 if (h)
55 i->g(); // expected-warning{{Called C++ object pointer is uninitialized}}
57 } // namespace ns1