1 // RUN: %clang_cc1 -Wno-unused -std=c++11 -analyze -analyzer-checker=debug.ExprInspection -verify %s 2 3 void clang_analyzer_eval(bool); 4 5 namespace pr17001_call_wrong_destructor { 6 bool x; 7 struct A { 8 int *a; 9 A() {} 10 ~A() {} 11 }; 12 struct B : public A { 13 B() {} 14 ~B() { x = true; } 15 }; 16 17 void f() { 18 { 19 const A &a = B(); 20 } 21 clang_analyzer_eval(x); // expected-warning{{TRUE}} 22 } 23 } // end namespace pr17001_call_wrong_destructor 24 25 namespace pr19539_crash_on_destroying_an_integer { 26 struct A { 27 int i; 28 int j[2]; 29 A() : i(1) { 30 j[0] = 2; 31 j[1] = 3; 32 } 33 ~A() {} 34 }; 35 36 void f() { 37 const int &x = A().i; // no-crash 38 const int &y = A().j[1]; // no-crash 39 const int &z = (A().j[1], A().j[0]); // no-crash 40 41 // FIXME: All of these should be TRUE, but constructors aren't inlined. 42 clang_analyzer_eval(x == 1); // expected-warning{{UNKNOWN}} 43 clang_analyzer_eval(y == 3); // expected-warning{{UNKNOWN}} 44 clang_analyzer_eval(z == 2); // expected-warning{{UNKNOWN}} 45 } 46 } // end namespace pr19539_crash_on_destroying_an_integer 47