1// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fobjc-arc -fblocks -Wimplicit-retain-self -verify %s 2// rdar://11194874 3 4typedef void (^BlockTy)(); 5 6void noescapeFunc(__attribute__((noescape)) BlockTy); 7void escapeFunc(BlockTy); 8 9@interface Root @end 10 11@interface I : Root 12{ 13 int _bar; 14} 15@end 16 17@implementation I 18 - (void)foo{ 19 ^{ 20 _bar = 3; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}} 21 }(); 22 } 23 24 - (void)testNested{ 25 noescapeFunc(^{ 26 (void)_bar; 27 escapeFunc(^{ 28 (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}} 29 noescapeFunc(^{ 30 (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}} 31 }); 32 (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}} 33 }); 34 (void)_bar; 35 }); 36 } 37 38 - (void)testLambdaInBlock{ 39 noescapeFunc(^{ [&](){ (void)_bar; }(); }); 40 escapeFunc(^{ [&](){ (void)_bar; }(); }); // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}} 41 } 42@end 43