[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
Tue Jun 24 10:31:48 PDT 2025
================
@@ -202,6 +202,25 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) {
handleSimpleAttribute<DeviceKernelAttr>(*this, D, AL);
}
+void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) {
+ auto *FD = cast<FunctionDecl>(D);
+ if (!FD->isExternallyVisible()) {
+ Diag(AL.getLoc(), diag::err_sycl_attribute_invalid_linkage);
+ return;
+ }
----------------
tahonermann wrote:
I think the check for external linkage is better done in `Sema::CheckFunctionDeclaration()` so that other semantic checking of the function is done first. See the call to `CheckSYCLEntryPointFunctionDecl()` there; perhaps it makes sense to replicate that redirection to a `CheckSYCLExternalFunctionDecl()` function defined here.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list