================
@@ -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:

@schittir and I discussed this today and concluded that this diagnostic can be 
unconditionally demoted to a warning. The attribute only affects whether an 
unused function definition is emitted or whether a definition is required for a 
used declaration. Calling convention isn't affected, so there is no strict 
requirement that the attribute be present on a declaration prior to use. The 
attribute doesn't affect visibility since the declaration is already required 
to have external linkage. If a backend needs to mark the symbol emitted in some 
way to make it visible to other device TUs, that can be done based on the 
attribute being present on any declaration. If we encounter a need for the 
attribute to be present on an earlier declaration for some backend, we can make 
change to elevate it to an error in those cases.

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

Reply via email to