blob: 95928ea552687982ddf92c02982ca4672c88aa25 [file] [log] [blame]
Ted Kremenek6c07bdb2009-06-26 00:05:51 +00001// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
Zhongxing Xue8e4d8c2008-11-20 00:46:15 +00002
3struct s {
4 int data;
5};
6
7struct s global;
8
9void g(int);
10
11void f4() {
12 int a;
13 if (global.data == 0)
14 a = 3;
Ted Kremenek42268462008-12-04 02:07:20 +000015 if (global.data == 0) // When the true branch is feasible 'a = 3'.
Zhongxing Xue8e4d8c2008-11-20 00:46:15 +000016 g(a); // no-warning
17}
Ted Kremenekc761f402009-08-28 20:25:33 +000018
19
20// Test uninitialized value due to part of the structure being uninitialized.
21struct TestUninit { int x; int y; };
22struct TestUninit test_uninit_aux();
23void test_uninit_pos() {
24 struct TestUninit v1 = { 0, 0 };
25 struct TestUninit v2 = test_uninit_aux();
26 int z;
27 v1.y = z;
28 test_unit_aux2(v2.x + v1.y); // expected-warning{{Pass-by-value argument in function call is undefined}}
29}
30void test_uninit_neg() {
31 struct TestUninit v1 = { 0, 0 };
32 struct TestUninit v2 = test_uninit_aux();
33 test_unit_aux2(v2.x + v1.y); // no-warning
34}
35