| // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s |
| if (global.data == 0) // When the true branch is feasible 'a = 3'. |
| // Test uninitialized value due to part of the structure being uninitialized. |
| struct TestUninit { int x; int y; }; |
| struct TestUninit test_uninit_aux(); |
| void test_unit_aux2(int); |
| struct TestUninit v1 = { 0, 0 }; |
| struct TestUninit v2 = test_uninit_aux(); |
| v1.y = z; // expected-warning{{Assigned value is garbage or undefined}} |
| test_unit_aux2(v2.x + v1.y); |
| void test_uninit_pos_2() { |
| struct TestUninit v1 = { 0, 0 }; |
| test_unit_aux2(v2.x + v1.y); // expected-warning{{The left operand of '+' is a garbage value}} |
| void test_uninit_pos_3() { |
| struct TestUninit v1 = { 0, 0 }; |
| test_unit_aux2(v1.y + v2.x); // expected-warning{{The right operand of '+' is a garbage value}} |
| struct TestUninit v1 = { 0, 0 }; |
| struct TestUninit v2 = test_uninit_aux(); |
| test_unit_aux2(v2.x + v1.y); // no-warning |