[cfe-commits] r80388 - /cfe/trunk/test/Analysis/uninit-vals-ps-region.c

Ted Kremenek kremenek at apple.com
Fri Aug 28 13:25:33 PDT 2009


Author: kremenek
Date: Fri Aug 28 15:25:33 2009
New Revision: 80388

URL: http://llvm.org/viewvc/llvm-project?rev=80388&view=rev
Log:
Add uninitialized values test case.

Modified:
    cfe/trunk/test/Analysis/uninit-vals-ps-region.c

Modified: cfe/trunk/test/Analysis/uninit-vals-ps-region.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps-region.c?rev=80388&r1=80387&r2=80388&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals-ps-region.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps-region.c Fri Aug 28 15:25:33 2009
@@ -15,3 +15,21 @@
   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
+}
+





More information about the cfe-commits mailing list