brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 28c8ec3 Raw
46 lines · plain
1// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fobjc-arc -fblocks -Wimplicit-retain-self -verify %s2 3typedef void (^BlockTy)();4 5void noescapeFunc(__attribute__((noescape)) BlockTy);6void escapeFunc(BlockTy);7 8@interface Root @end9 10@interface I : Root11{12  int _bar;13}14@end15 16@implementation I17  - (void)foo{18      ^{19           _bar = 3; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}20       }();21  }22 23  - (void)testNested{24    noescapeFunc(^{25      (void)_bar;26      escapeFunc(^{27        (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}28        noescapeFunc(^{29          (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}30        });31        (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}32      });33      (void)_bar;34    });35  }36 37  - (void)testLambdaInBlock{38    noescapeFunc(^{ [&](){ (void)_bar; }(); });39    escapeFunc(^{ [&](){ (void)_bar; }(); }); // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}40  }41 42  - (BlockTy)testDeclType{43    return ^{ decltype(_bar) i = 12; (void)i; };44  }45@end46