[Sema][ObjC] Don't warn about implicitly-retained self in an unevaluated

context
This commit is contained in:
Akira Hatanaka 2022-08-22 12:13:48 -07:00
parent ced705c440
commit 5d794552bc
2 changed files with 5 additions and 1 deletions

View File

@ -2946,7 +2946,7 @@ ExprResult Sema::BuildIvarRefExpr(Scope *S, SourceLocation Loc,
!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
getCurFunction()->recordUseOfWeak(Result);
}
if (getLangOpts().ObjCAutoRefCount)
if (getLangOpts().ObjCAutoRefCount && !isUnevaluatedContext())
if (const BlockDecl *BD = CurContext->getInnermostBlockDecl())
ImplicitlyRetainedSelfLocs.push_back({Loc, BD});

View File

@ -39,4 +39,8 @@ void escapeFunc(BlockTy);
noescapeFunc(^{ [&](){ (void)_bar; }(); });
escapeFunc(^{ [&](){ (void)_bar; }(); }); // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
}
- (BlockTy)testDeclType{
return ^{ decltype(_bar) i = 12; (void)i; };
}
@end