[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 Jul 23 10:30:51 PDT 2025
================
@@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
diag::note_carries_dependency_missing_first_decl) << 0/*Function*/;
}
+ // SYCL 2020 section 5.10.1, "SYCL functions and member functions linkage":
+ // When a function is declared with SYCL_EXTERNAL, that macro must be
+ // used on the first declaration of that function in the translation unit.
+ // Redeclarations of the function in the same translation unit may
+ // optionally use SYCL_EXTERNAL, but this is not required.
+ const SYCLExternalAttr *SEA = New->getAttr<SYCLExternalAttr>();
+ if (SEA && !Old->hasAttr<SYCLExternalAttr>()) {
----------------
tahonermann wrote:
That might be reasonable. I think we might still have to make it an error if there was an ODR-use before the definition though. I'd have to think about that more.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list