2009-06-26 08:05:51 +08:00
|
|
|
// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
|
2008-11-20 08:46:15 +08:00
|
|
|
|
|
|
|
struct s {
|
|
|
|
int data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct s global;
|
|
|
|
|
|
|
|
void g(int);
|
|
|
|
|
|
|
|
void f4() {
|
|
|
|
int a;
|
|
|
|
if (global.data == 0)
|
|
|
|
a = 3;
|
2008-12-04 10:07:20 +08:00
|
|
|
if (global.data == 0) // When the true branch is feasible 'a = 3'.
|
2008-11-20 08:46:15 +08:00
|
|
|
g(a); // no-warning
|
|
|
|
}
|
2009-08-29 04:25:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Test uninitialized value due to part of the structure being uninitialized.
|
|
|
|
struct TestUninit { int x; int y; };
|
|
|
|
struct TestUninit test_uninit_aux();
|
|
|
|
void test_uninit_pos() {
|
|
|
|
struct TestUninit v1 = { 0, 0 };
|
|
|
|
struct TestUninit v2 = test_uninit_aux();
|
|
|
|
int z;
|
|
|
|
v1.y = z;
|
2009-09-24 08:44:26 +08:00
|
|
|
test_unit_aux2(v2.x + v1.y); // expected-warning{{The right operand of '+' is a garbage value}}
|
2009-08-29 04:25:33 +08:00
|
|
|
}
|
|
|
|
void test_uninit_neg() {
|
|
|
|
struct TestUninit v1 = { 0, 0 };
|
|
|
|
struct TestUninit v2 = test_uninit_aux();
|
|
|
|
test_unit_aux2(v2.x + v1.y); // no-warning
|
|
|
|
}
|
|
|
|
|