[clang] [SYCL] Basic diagnostics for the sycl_kernel_entry_point attribute. (PR #120327)
Tom Honermann via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 18 11:15:50 PST 2024
================
@@ -206,3 +208,124 @@ void SemaSYCL::handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL) {
D->addAttr(::new (SemaRef.Context)
SYCLKernelEntryPointAttr(SemaRef.Context, AL, TSI));
}
+
+static SourceLocation SourceLocationForType(QualType QT) {
+ SourceLocation Loc;
+ const Type *T = QT->getUnqualifiedDesugaredType();
+ if (const TagType *TT = dyn_cast<TagType>(T))
+ Loc = TT->getDecl()->getLocation();
+ else if (const ObjCInterfaceType *ObjCIT = dyn_cast<ObjCInterfaceType>(T))
+ Loc = ObjCIT->getDecl()->getLocation();
+ return Loc;
+}
+
+static bool CheckSYCLKernelName(Sema &S, SourceLocation Loc,
+ QualType KernelName) {
+ assert(!KernelName->isDependentType());
+
+ if (!KernelName->isStructureOrClassType()) {
----------------
tahonermann wrote:
`isStructureOrClassType()` excludes unions (but includes Microsoft's `__interface` types; we could exclude those); see [here](https://github.com/llvm/llvm-project/blob/2b932bc111c0d96db7044b0a854d7ad763710df2/clang/lib/AST/Type.cpp#L690-L696).
The SYCL 2020 specification is imprecise; see [here](https://github.com/KhronosGroup/SYCL-Docs/issues/568) for an issue I previously reported against it. For now, I've been taking a conservative view and restricting what is allowed to just non-union class types. We can then lift these restrictions once the SYCL specification is clarified.
https://github.com/llvm/llvm-project/pull/120327
More information about the cfe-commits
mailing list