|
54 | 54 | #include "clang/Sema/SemaPPC.h" |
55 | 55 | #include "clang/Sema/SemaRISCV.h" |
56 | 56 | #include "clang/Sema/SemaSwift.h" |
| 57 | +#include "clang/Sema/SemaSYCL.h" |
57 | 58 | #include "clang/Sema/SemaWasm.h" |
58 | 59 | #include "clang/Sema/Template.h" |
59 | 60 | #include "llvm/ADT/STLForwardCompat.h" |
@@ -3017,6 +3018,16 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) { |
3017 | 3018 | // declarations after definitions. |
3018 | 3019 | ++I; |
3019 | 3020 | continue; |
| 3021 | + } else if (isa<SYCLKernelEntryPointAttr>(NewAttribute)) { |
| 3022 | + // Elevate latent uses of the sycl_kernel_entry_point attribute to an |
| 3023 | + // error since the definition will have already been created without |
| 3024 | + // the semantic effects of the attribute having been applied. |
| 3025 | + S.Diag(NewAttribute->getLocation(), |
| 3026 | + diag::err_sycl_entry_point_after_definition); |
| 3027 | + S.Diag(Def->getLocation(), diag::note_previous_definition); |
| 3028 | + New->setInvalidDecl(); |
| 3029 | + ++I; |
| 3030 | + continue; |
3020 | 3031 | } |
3021 | 3032 |
|
3022 | 3033 | S.Diag(NewAttribute->getLocation(), |
@@ -12053,6 +12064,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, |
12053 | 12064 | if (LangOpts.OpenMP) |
12054 | 12065 | OpenMP().ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(NewFD); |
12055 | 12066 |
|
| 12067 | + if (LangOpts.isSYCL() && NewFD->hasAttr<SYCLKernelEntryPointAttr>()) |
| 12068 | + SYCL().CheckSYCLEntryPointFunctionDecl(NewFD); |
| 12069 | + |
12056 | 12070 | // Semantic checking for this function declaration (in isolation). |
12057 | 12071 |
|
12058 | 12072 | if (getLangOpts().CPlusPlus) { |
@@ -12285,6 +12299,13 @@ void Sema::CheckMain(FunctionDecl *FD, const DeclSpec &DS) { |
12285 | 12299 | return; |
12286 | 12300 | } |
12287 | 12301 |
|
| 12302 | + if (getLangOpts().isSYCL() && FD->hasAttr<SYCLKernelEntryPointAttr>()) { |
| 12303 | + Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(), |
| 12304 | + diag::err_sycl_entry_point_on_main); |
| 12305 | + FD->setInvalidDecl(); |
| 12306 | + return; |
| 12307 | + } |
| 12308 | + |
12288 | 12309 | // Functions named main in hlsl are default entries, but don't have specific |
12289 | 12310 | // signatures they are required to conform to. |
12290 | 12311 | if (getLangOpts().HLSL) |
@@ -15841,6 +15862,27 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, |
15841 | 15862 | CheckCoroutineWrapper(FD); |
15842 | 15863 | } |
15843 | 15864 |
|
| 15865 | + // Create SYCL kernel entry point function outline. |
| 15866 | + if (FD && !FD->isInvalidDecl() && !FD->isDependentContext() && |
| 15867 | + FD->hasAttr<SYCLKernelEntryPointAttr>()) { |
| 15868 | + if (FD->isDeleted()) { |
| 15869 | + Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(), |
| 15870 | + diag::err_sycl_entry_point_invalid) |
| 15871 | + << /*deleted function*/2; |
| 15872 | + FD->setInvalidDecl(); |
| 15873 | + } else if (FD->isDefaulted()) { |
| 15874 | + Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(), |
| 15875 | + diag::err_sycl_entry_point_invalid) |
| 15876 | + << /*defaulted function*/3; |
| 15877 | + FD->setInvalidDecl(); |
| 15878 | + } else if (FSI->isCoroutine()) { |
| 15879 | + Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(), |
| 15880 | + diag::err_sycl_entry_point_invalid) |
| 15881 | + << /*coroutine*/7; |
| 15882 | + FD->setInvalidDecl(); |
| 15883 | + } |
| 15884 | + } |
| 15885 | + |
15844 | 15886 | { |
15845 | 15887 | // Do not call PopExpressionEvaluationContext() if it is a lambda because |
15846 | 15888 | // one is already popped when finishing the lambda in BuildLambdaExpr(). |
|
0 commit comments