blob: a287002db740ebab982deb88b8fb1bc972837aae [file] [log] [blame]
Ted Kremenek9f490552008-11-21 00:15:15 +00001// RUN: clang -checker-simple -verify %s &&
2// RUN: clang -checker-simple -analyzer-store-region -verify %s
Ted Kremenek43ae4b02008-04-24 18:28:14 +00003
4struct FPRec {
5 void (*my_func)(int * x);
6};
7
8int bar(int x);
9
10int f1_a(struct FPRec* foo) {
11 int x;
12 (*foo->my_func)(&x);
13 return bar(x)+1; // no-warning
14}
15
16int f1_b() {
17 int x;
18 return bar(x)+1; // expected-warning{{Pass-by-value argument in function is undefined.}}
19}
Ted Kremenek5c454ab2008-05-05 15:56:53 +000020
21int f2() {
22
23 int x;
24
25 if (x+1) // expected-warning{{Branch}}
26 return 1;
27
28 return 2;
29}
30
31int f2_b() {
32 int x;
33
34 return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
35}
36
Ted Kremenek5c96c272008-05-21 15:48:33 +000037int f3(void) {
38 int i;
39 int *p = &i;
40 if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
41 return 0;
42 else
43 return 1;
44}
Zhongxing Xu89e8a072008-11-19 11:10:42 +000045