diff options
Diffstat (limited to 'test/Analysis/blocks.m')
-rw-r--r-- | test/Analysis/blocks.m | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index ef43751ce1b8..e8e96a22cf9e 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -checker-cfref -analyzer-store=region -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from Mac OS X headers: @@ -67,3 +67,19 @@ void test1(NSString *format, ...) { __builtin_va_end(args); } + +// test2 - Test that captured variables that are uninitialized are flagged +// as such. +void test2() { + static int y = 0; + int x; + ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is captured by block with a garbage value}} +} + +void test2_b() { + static int y = 0; + __block int x; + // This is also a bug, but should be found not by checking the value + // 'x' is bound at block creation. + ^{ y = x + 1; }(); // no-warning +} |