blob: 124eef32fde37ccc39728d4b3305402e157246f2 [file] [log] [blame]
Artem Dergachev28ee2d12016-11-30 19:02:44 +00001// RUN: %clang_cc1 -Wno-unused -std=c++11 -analyze -analyzer-checker=debug.ExprInspection -verify %s
2
3void clang_analyzer_eval(bool);
4
5namespace pr17001_call_wrong_destructor {
6bool x;
7struct A {
8 int *a;
9 A() {}
10 ~A() {}
11};
12struct B : public A {
13 B() {}
14 ~B() { x = true; }
15};
16
17void 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
25namespace pr19539_crash_on_destroying_an_integer {
26struct 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
36void 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