blob: c4c02af55da72cf072fab3f32c81205413b20ff4 [file] [log] [blame]
Ted Kremenek8e1e5bd2008-04-24 18:28:14 +00001// RUN: clang -checker-simple -verify %s
2
3struct FPRec {
4 void (*my_func)(int * x);
5};
6
7int bar(int x);
8
9int f1_a(struct FPRec* foo) {
10 int x;
11 (*foo->my_func)(&x);
12 return bar(x)+1; // no-warning
13}
14
15int f1_b() {
16 int x;
17 return bar(x)+1; // expected-warning{{Pass-by-value argument in function is undefined.}}
18}
Ted Kremenek75439aa2008-05-05 15:56:53 +000019
20int f2() {
21
22 int x;
23
24 if (x+1) // expected-warning{{Branch}}
25 return 1;
26
27 return 2;
28}
29
30int f2_b() {
31 int x;
32
33 return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
34}
35
Ted Kremenekbb9bd732008-05-21 15:48:33 +000036int f3(void) {
37 int i;
38 int *p = &i;
39 if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
40 return 0;
41 else
42 return 1;
43}
Zhongxing Xu9bd8b4c2008-11-19 11:10:42 +000044
45// RUN: clang -checker-simple -analyzer-store-region -verify %s
46
47struct s {
48 int data;
49};
50
51struct s global;
52
53void g(int);
54
55void f4() {
56 int a;
57 if (global.data == 0)
58 a = 3;
59 if (global.data == 0)
60 g(a); // no-warning
61}