diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 056b93dc86ee75a4a202e24ed494c01956054456..d398f7b12d2583814f1f989ae6e95493e7e95b8d 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -3412,6 +3412,15 @@ void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, } } assert(ContextIsFound && "no null type for '__context' parameter"); + if (!ContextIsFound) { + // Add __context implicitly if it is not specified. + IdentifierInfo *ParamName = &Context.Idents.get("__context"); + QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD)); + ImplicitParamDecl *Param = + ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType); + DC->addDecl(Param); + CD->setContextParam(ParamNum, Param); + } // Enter the capturing scope for this captured region. PushCapturedRegionScope(CurScope, CD, RD, Kind);