[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)
Tom Honermann via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 13 20:52:08 PDT 2025
================
@@ -250,6 +250,20 @@ static bool CheckSYCLKernelName(Sema &S, SourceLocation Loc,
return false;
}
+void SemaSYCL::CheckSYCLExternalFunctionDecl(FunctionDecl *FD) {
+ const auto *SEAttr = FD->getAttr<SYCLExternalAttr>();
+ assert(SEAttr && "Missing sycl_external attribute");
+ if (!FD->isExternallyVisible()) {
+ Diag(SEAttr->getLocation(), diag::err_sycl_external_invalid_linkage)
+ << SEAttr;
+ }
----------------
tahonermann wrote:
This change will suffice to address the diagnostic issues with explicit and implicit template instantiations. There will still be some issues with explicit specializations due to attributes inherited from the implicit instantiation of the corresponding declaration from the primary template, but that's ok for now.
```suggestion
if (!FD->isInvalidDecl() && !FD->isTemplated()) {
if (!FD->isExternallyVisible())
if (!FD->isFunctionTemplateSpecialization() ||
FD->getTemplateSpecializationInfo()->isExplicitSpecialization())
Diag(SEAttr->getLocation(), diag::err_sycl_external_invalid_linkage)
<< SEAttr;
```
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list