From: Ted Kremenek Date: Fri, 28 Aug 2009 20:25:33 +0000 (+0000) Subject: Add uninitialized values test case. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c761f40467a76c5bba819324ddc489c214c5a5da;p=clang Add uninitialized values test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80388 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/uninit-vals-ps-region.c b/test/Analysis/uninit-vals-ps-region.c index 32f787db4a..95928ea552 100644 --- a/test/Analysis/uninit-vals-ps-region.c +++ b/test/Analysis/uninit-vals-ps-region.c @@ -15,3 +15,21 @@ void f4() { if (global.data == 0) // When the true branch is feasible 'a = 3'. g(a); // no-warning } + + +// 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; + test_unit_aux2(v2.x + v1.y); // expected-warning{{Pass-by-value argument in function call is undefined}} +} +void test_uninit_neg() { + struct TestUninit v1 = { 0, 0 }; + struct TestUninit v2 = test_uninit_aux(); + test_unit_aux2(v2.x + v1.y); // no-warning +} +