blob: 2bc7fb32547b85bf2f3bbee7b5c5dee80fbe226b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-experimental -fsyntax-only %s -verify
int test1_aux(int &x);
int test1() {
int x;
test1_aux(x);
return x; // no-warning
}
int test2_aux() {
int x;
int &y = x;
return x; // no-warning
}
// Handle cases where the CFG may constant fold some branches, thus
// mitigating the need for some path-sensitivity in the analysis.
unsigned test3_aux();
unsigned test3() {
unsigned x = 0;
const bool flag = true;
if (flag && (x = test3_aux()) == 0) {
return x;
}
return x;
}
unsigned test3_b() {
unsigned x ;
const bool flag = true;
if (flag && (x = test3_aux()) == 0) {
x = 1;
}
return x; // no-warning
}
unsigned test3_c() {
unsigned x; // expected-note{{declared here}} expected-note{{add initialization}}
const bool flag = false;
if (flag && (x = test3_aux()) == 0) {
x = 1;
}
return x; // expected-warning{{variable 'x' is possibly uninitialized when used here}}
}
enum test4_A {
test4_A_a, test_4_A_b
};
test4_A test4() {
test4_A a; // expected-note{{variable 'a' is declared here}}
return a; // expected-warning{{variable 'a' is possibly uninitialized when used here}}
}
|