diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 59918464148c..eb1690c00788 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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}); diff --git a/clang/test/SemaObjCXX/warn-implicit-self-in-block.mm b/clang/test/SemaObjCXX/warn-implicit-self-in-block.mm index 4842b4b10ba9..7cc811b6b056 100644 --- a/clang/test/SemaObjCXX/warn-implicit-self-in-block.mm +++ b/clang/test/SemaObjCXX/warn-implicit-self-in-block.mm @@ -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