| 1 |
// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify %s |
| 2 |
|
| 3 |
void clang_analyzer_eval(bool); |
| 4 |
|
| 5 |
struct s { int a; }; |
| 6 |
void foo() { |
| 7 |
auto [a] = s{1}; |
| 8 |
clang_analyzer_eval(a == 1); // expected-warning{{TRUE}} |
| 9 |
} |
| 10 |
|
| 11 |
struct s2 { |
| 12 |
int &x; |
| 13 |
}; |
| 14 |
|
| 15 |
int *foo2(s2 in) { |
| 16 |
auto [a] = in; |
| 17 |
return &a; |
| 18 |
} |
| 19 |
|
| 20 |
void bar() { |
| 21 |
int i = 1; |
| 22 |
s2 a{i}; |
| 23 |
|
| 24 |
auto *x = foo2(a); |
| 25 |
|
| 26 |
clang_analyzer_eval(*x == i); // expected-warning{{TRUE}} |
| 27 |
|
| 28 |
*x = 2; |
| 29 |
|
| 30 |
clang_analyzer_eval(*x == 2); // expected-warning{{TRUE}} |
| 31 |
clang_analyzer_eval(i == 2); // expected-warning{{TRUE}} |
| 32 |
} |