2008-11-21 08:15:15 +08:00
|
|
|
// RUN: clang -checker-simple -verify %s &&
|
|
|
|
// RUN: clang -checker-simple -analyzer-store-region -verify %s
|
2008-04-25 02:28:14 +08:00
|
|
|
|
|
|
|
struct FPRec {
|
|
|
|
void (*my_func)(int * x);
|
|
|
|
};
|
|
|
|
|
|
|
|
int bar(int x);
|
|
|
|
|
|
|
|
int f1_a(struct FPRec* foo) {
|
|
|
|
int x;
|
|
|
|
(*foo->my_func)(&x);
|
|
|
|
return bar(x)+1; // no-warning
|
|
|
|
}
|
|
|
|
|
|
|
|
int f1_b() {
|
|
|
|
int x;
|
|
|
|
return bar(x)+1; // expected-warning{{Pass-by-value argument in function is undefined.}}
|
|
|
|
}
|
2008-05-05 23:56:53 +08:00
|
|
|
|
|
|
|
int f2() {
|
|
|
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
if (x+1) // expected-warning{{Branch}}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int f2_b() {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
|
|
|
|
}
|
|
|
|
|
2008-05-21 23:48:33 +08:00
|
|
|
int f3(void) {
|
|
|
|
int i;
|
|
|
|
int *p = &i;
|
|
|
|
if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
2008-11-19 19:10:42 +08:00
|
|
|
|
2008-11-21 08:28:47 +08:00
|
|
|
int ret_uninit() {
|
|
|
|
int i;
|
|
|
|
int *p = &i;
|
|
|
|
return *p; // expected-warning{{Uninitialized or undefined return value returned to caller.}}
|
|
|
|
}
|
|
|
|
|
|
|
|
|