================ @@ -4084,6 +4084,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, diag::note_carries_dependency_missing_first_decl) << 0/*Function*/; } + // SYCL spec 2020 + // The first declaration of a function with external linkage must + // specify sycl_external attribute. + // Subsequent declarations may optionally specify this attribute. + if (LangOpts.SYCLIsDevice) { + const SYCLExternalAttr *SEA = New->getAttr<SYCLExternalAttr>(); + if (SEA && !Old->hasAttr<SYCLExternalAttr>()) { + Diag(SEA->getLocation(), diag::err_sycl_attribute_missing_on_first_decl) + << SEA; + Diag(Old->getLocation(), diag::note_previous_declaration); + } ---------------- tahonermann wrote:
In most cases where this diagnostic is issued, the attribute is also dropped from the new declaration. I think we should do similarly here. See examples [here](https://github.com/llvm/llvm-project/blob/13c897093fd8d40ee3a5b13ff9c0b38c89e72bf1/clang/lib/Sema/SemaDecl.cpp#L3673-L3687) and [here](https://github.com/llvm/llvm-project/blob/13c897093fd8d40ee3a5b13ff9c0b38c89e72bf1/clang/lib/Sema/SemaDecl.cpp#L4620-L4626). A counter example (which might be a bug) is [here](https://github.com/llvm/llvm-project/blob/13c897093fd8d40ee3a5b13ff9c0b38c89e72bf1/clang/lib/Sema/SemaDecl.cpp#L4068-L4073). ```suggestion New->dropAttr<SYCLExternalAttr>(); } ``` https://github.com/llvm/llvm-project/pull/140282 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits