Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / structured_bindings.cpp
blob7004c2e7dcf43f99172c62c5aa7d431ea8732229
1 // RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify %s
3 void clang_analyzer_eval(bool);
5 struct s { int a; };
6 int foo() {
7 auto [a] = s{1};
8 clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
9 } // expected-warning{{non-void function does not return a value}}
11 struct s2 {
12 int &x;
15 int *foo2(s2 in) {
16 auto [a] = in;
17 return &a;
20 void bar() {
21 int i = 1;
22 s2 a{i};
24 auto *x = foo2(a);
26 clang_analyzer_eval(*x == i); // expected-warning{{TRUE}}
28 *x = 2;
30 clang_analyzer_eval(*x == 2); // expected-warning{{TRUE}}
31 clang_analyzer_eval(i == 2); // expected-warning{{TRUE}}