recursively captured.
Under ARC, a block variable is zero-initialized when it is recursively
captured by the block literal initializer.
rdar://problem/
11022762
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359049
91177308-0d34-0410-b5e6-
96231b3b80d8
def note_uninit_var_use : Note<
"%select{uninitialized use occurs|variable is captured by block}0 here">;
def warn_uninit_byref_blockvar_captured_by_block : Warning<
- "block pointer variable %0 is uninitialized when captured by block">,
- InGroup<Uninitialized>, DefaultIgnore;
+ "block pointer variable %0 is %select{uninitialized|null}1 when captured by "
+ "block">, InGroup<Uninitialized>, DefaultIgnore;
def note_block_var_fixit_add_initialization : Note<
"did you mean to use __block %0?">;
def note_in_omitted_aggregate_initializer : Note<
if (VD->getType()->isBlockPointerType() && !VD->hasAttr<BlocksAttr>())
S.Diag(BE->getBeginLoc(),
diag::warn_uninit_byref_blockvar_captured_by_block)
- << VD->getDeclName();
+ << VD->getDeclName()
+ << VD->getType().getQualifiers().hasObjCLifetime();
else
DiagUninitUse(S, VD, Use, true);
}
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -x objective-c -fobjc-arc -DARC -verify %s
// rdar://10817031
int main() {
- void (^arc_fail)() = ^() { // expected-warning {{block pointer variable 'arc_fail' is uninitialized when captured by block}} \
- // expected-note {{did you mean to use __block 'arc_fail'}}
+ void (^arc_fail)() = ^() {
+#ifdef ARC
+// expected-warning@-2 {{block pointer variable 'arc_fail' is null when captured by block}}
+#else
+// expected-warning@-4 {{block pointer variable 'arc_fail' is uninitialized when captured by block}}
+#endif
+// expected-note@-6 {{did you mean to use __block 'arc_fail'}}
arc_fail(); // BOOM
};
}
-// CHECK: {7:12-7:12}:"__block "
+// CHECK: {8:12-8:12}:"__block "