blob: bb0b8a49e740e325f6caa454abfac86e75f3430d (
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
|
// RUN: clang-cc -analyze -warn-uninit-values -verify %s
int f1() {
int x;
return x; // expected-warning {{use of uninitialized variable}}
}
int f2(int x) {
int y;
int z = x + y; // expected-warning {{use of uninitialized variable}}
return z;
}
int f3(int x) {
int y;
return x ? 1 : y; // expected-warning {{use of uninitialized variable}}
}
int f4(int x) {
int y;
if (x) y = 1;
return y; // expected-warning {{use of uninitialized variable}}
}
int f5() {
int a;
a = 30; // no-warning
}
void f6(int i) {
int x;
for (i = 0 ; i < 10; i++)
printf("%d",x++); // expected-warning {{use of uninitialized variable}} \
// expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
void f7(int i) {
int x = i;
int y;
for (i = 0; i < 10; i++ ) {
printf("%d",x++); // no-warning
x += y; // expected-warning {{use of uninitialized variable}}
}
}
|