diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2eba7efa6fd..83b32d36fbf 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -13187,6 +13187,23 @@ Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D, D.setFunctionDefinitionKind(FDK_Definition); Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists); + + if (LangOpts.CPlusPlusAMP && SkipBody) { + const bool IsAuto = DP->hasAttr(); + const bool IsHC = DP->hasAttr(); + const bool IsCPU = DP->hasAttr(); + + SkipBody->ShouldSkip = + !IsAuto && (LangOpts.DevicePath ? (!IsHC && IsCPU) : (IsHC && !IsCPU)); + + if (SkipBody->ShouldSkip) { + auto Empty = new (getASTContext()) NullStmt{DP->getLocation()}; + cast(DP)->setBody(Empty); + cast(DP)->addAttr(CXX11NoReturnAttr::CreateImplicit(getASTContext())); + return DP; + } + } + return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody); }