[clang] [SYCL] Restrict the sycl_kernel_entry_point attribute spelling to C++11 style. (PR #151405)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 31 14:01:15 PDT 2025


https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/151405

>From 17fd9871a422cb2b4c3697b66011ae7f5c84379d Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom.honermann at intel.com>
Date: Wed, 30 Jul 2025 14:52:03 -0700
Subject: [PATCH 1/2] [SYCL] Restrict the sycl_kernel_entry_point attribute
 spelling to C++11 style.

Previously, the `sycl_kernel_entry_point` attribute could be specified
using either the GNU or C++11 spelling styles. Future SYCL attributes
are expected to support only the C++11 spelling style, so support for
the GNU style is being removed.

In order to ensure consistent presentation of the attribute in
diagnostic messages, diagnostics specific to this attribute now
require the attribute to be provided as an argument. This delegates
formatting of the attribute name to the diagnostic engine.

As an additional nicety, "the" is added to some diagnostic messages so
that they read more like proper sentences.
---
 clang/include/clang/Basic/Attr.td             |  2 +-
 .../clang/Basic/DiagnosticSemaKinds.td        | 24 ++++-----
 clang/lib/Sema/SemaDecl.cpp                   | 11 ++--
 clang/lib/Sema/SemaSYCL.cpp                   | 31 ++++++-----
 clang/lib/Serialization/ASTReaderDecl.cpp     |  3 +-
 .../ast-dump-sycl-kernel-entry-point.cpp      |  6 +--
 ...-kernel-entry-point-attr-appertainment.cpp | 53 ++++++++++---------
 ...el-entry-point-attr-kernel-name-module.cpp | 12 ++---
 ...ernel-entry-point-attr-kernel-name-pch.cpp |  4 +-
 ...cl-kernel-entry-point-attr-kernel-name.cpp | 16 +++---
 10 files changed, 84 insertions(+), 78 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 224cb6a32af28..b3ff45b3e90a3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1642,7 +1642,7 @@ def DeviceKernel : DeclOrTypeAttr {
 }
 
 def SYCLKernelEntryPoint : InheritableAttr {
-  let Spellings = [Clang<"sycl_kernel_entry_point">];
+  let Spellings = [CXX11<"clang", "sycl_kernel_entry_point">];
   let Args = [
     // KernelName is required and specifies the kernel name type.
     TypeArgument<"KernelName">,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 27d2152805f97..94b174c758a5c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12936,31 +12936,29 @@ def err_sycl_special_type_num_init_method : Error<
 
 // SYCL kernel entry point diagnostics
 def err_sycl_entry_point_invalid : Error<
-  "'sycl_kernel_entry_point' attribute cannot be applied to a"
+  "the %0 attribute cannot be applied to a"
   " %select{non-static member function|variadic function|deleted function|"
            "defaulted function|constexpr function|consteval function|"
            "function declared with the 'noreturn' attribute|coroutine|"
-           "function defined with a function try block}0">;
+           "function defined with a function try block}1">;
 def err_sycl_entry_point_invalid_redeclaration : Error<
-  "'sycl_kernel_entry_point' kernel name argument does not match prior"
-  " declaration%diff{: $ vs $|}0,1">;
+  "the %0 kernel name argument does not match prior"
+  " declaration%diff{: $ vs $|}1,2">;
 def err_sycl_kernel_name_conflict : Error<
-  "'sycl_kernel_entry_point' kernel name argument conflicts with a previous"
-  " declaration">;
+  "the %0 kernel name argument conflicts with a previous declaration">;
 def warn_sycl_kernel_name_not_a_class_type : Warning<
   "%0 is not a valid SYCL kernel name type; a non-union class type is required">,
   InGroup<DiagGroup<"nonportable-sycl">>, DefaultError;
 def warn_sycl_entry_point_redundant_declaration : Warning<
-  "redundant 'sycl_kernel_entry_point' attribute">, InGroup<RedundantAttribute>;
+  "redundant %0 attribute">, InGroup<RedundantAttribute>;
 def err_sycl_entry_point_after_definition : Error<
-  "'sycl_kernel_entry_point' attribute cannot be added to a function after the"
-  " function is defined">;
+  "the %0 attribute cannot be added to a function after the function is"
+  " defined">;
 def err_sycl_entry_point_return_type : Error<
-  "'sycl_kernel_entry_point' attribute only applies to functions with a"
-  " 'void' return type">;
+  "the %0 attribute only applies to functions with a 'void' return type">;
 def err_sycl_entry_point_deduced_return_type : Error<
-  "'sycl_kernel_entry_point' attribute only applies to functions with a"
-  " non-deduced 'void' return type">;
+  "the %0 attribute only applies to functions with a non-deduced 'void' return"
+  " type">;
 
 def warn_cuda_maxclusterrank_sm_90 : Warning<
   "maxclusterrank requires sm_90 or higher, CUDA arch provided: %0, ignoring "
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c7e75072da106..c6a586ad5f53a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3063,7 +3063,8 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
       // error since the definition will have already been created without
       // the semantic effects of the attribute having been applied.
       S.Diag(NewAttribute->getLocation(),
-             diag::err_sycl_entry_point_after_definition);
+             diag::err_sycl_entry_point_after_definition)
+                 << NewAttribute;
       S.Diag(Def->getLocation(), diag::note_previous_definition);
       cast<SYCLKernelEntryPointAttr>(NewAttribute)->setInvalidAttr();
       ++I;
@@ -16258,19 +16259,19 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
         FD->getAttr<SYCLKernelEntryPointAttr>();
     if (FD->isDefaulted()) {
       Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-          << /*defaulted function*/ 3;
+          << SKEPAttr << /*defaulted function*/ 3;
       SKEPAttr->setInvalidAttr();
     } else if (FD->isDeleted()) {
       Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-          << /*deleted function*/ 2;
+          << SKEPAttr << /*deleted function*/ 2;
       SKEPAttr->setInvalidAttr();
     } else if (FSI->isCoroutine()) {
       Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-          << /*coroutine*/ 7;
+          << SKEPAttr << /*coroutine*/ 7;
       SKEPAttr->setInvalidAttr();
     } else if (Body && isa<CXXTryStmt>(Body)) {
       Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-          << /*function defined with a function try block*/ 8;
+          << SKEPAttr << /*function defined with a function try block*/ 8;
       SKEPAttr->setInvalidAttr();
     }
 
diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index 3e03cb4bd5f99..3bd20aaf19b0d 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -262,12 +262,13 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
     if (!getASTContext().hasSameType(SAI->getKernelName(),
                                      SKEPAttr->getKernelName())) {
       Diag(SAI->getLocation(), diag::err_sycl_entry_point_invalid_redeclaration)
-          << SAI->getKernelName() << SKEPAttr->getKernelName();
+          << SKEPAttr << SAI->getKernelName() << SKEPAttr->getKernelName();
       Diag(SKEPAttr->getLocation(), diag::note_previous_attribute);
       SAI->setInvalidAttr();
     } else {
       Diag(SAI->getLocation(),
-           diag::warn_sycl_entry_point_redundant_declaration);
+           diag::warn_sycl_entry_point_redundant_declaration)
+               << SAI;
       Diag(SKEPAttr->getLocation(), diag::note_previous_attribute);
     }
   }
@@ -289,7 +290,8 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
                                        PrevSKEPAttr->getKernelName())) {
         Diag(SKEPAttr->getLocation(),
              diag::err_sycl_entry_point_invalid_redeclaration)
-            << SKEPAttr->getKernelName() << PrevSKEPAttr->getKernelName();
+            << SKEPAttr << SKEPAttr->getKernelName()
+            << PrevSKEPAttr->getKernelName();
         Diag(PrevSKEPAttr->getLocation(), diag::note_previous_decl) << PrevFD;
         SKEPAttr->setInvalidAttr();
       }
@@ -299,50 +301,52 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
   if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
     if (!MD->isStatic()) {
       Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-          << /*non-static member function*/ 0;
+          << SKEPAttr << /*non-static member function*/ 0;
       SKEPAttr->setInvalidAttr();
     }
   }
 
   if (FD->isVariadic()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*variadic function*/ 1;
+        << SKEPAttr << /*variadic function*/ 1;
     SKEPAttr->setInvalidAttr();
   }
 
   if (FD->isDefaulted()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*defaulted function*/ 3;
+        << SKEPAttr << /*defaulted function*/ 3;
     SKEPAttr->setInvalidAttr();
   } else if (FD->isDeleted()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*deleted function*/ 2;
+        << SKEPAttr << /*deleted function*/ 2;
     SKEPAttr->setInvalidAttr();
   }
 
   if (FD->isConsteval()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*consteval function*/ 5;
+        << SKEPAttr << /*consteval function*/ 5;
     SKEPAttr->setInvalidAttr();
   } else if (FD->isConstexpr()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*constexpr function*/ 4;
+        << SKEPAttr << /*constexpr function*/ 4;
     SKEPAttr->setInvalidAttr();
   }
 
   if (FD->isNoReturn()) {
     Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_invalid)
-        << /*function declared with the 'noreturn' attribute*/ 6;
+        << SKEPAttr << /*function declared with the 'noreturn' attribute*/ 6;
     SKEPAttr->setInvalidAttr();
   }
 
   if (FD->getReturnType()->isUndeducedType()) {
     Diag(SKEPAttr->getLocation(),
-         diag::err_sycl_entry_point_deduced_return_type);
+         diag::err_sycl_entry_point_deduced_return_type)
+             << SKEPAttr;
     SKEPAttr->setInvalidAttr();
   } else if (!FD->getReturnType()->isDependentType() &&
              !FD->getReturnType()->isVoidType()) {
-    Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_return_type);
+    Diag(SKEPAttr->getLocation(), diag::err_sycl_entry_point_return_type)
+        << SKEPAttr;
     SKEPAttr->setInvalidAttr();
   }
 
@@ -354,7 +358,8 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
       if (!declaresSameEntity(FD, SKI->getKernelEntryPointDecl())) {
         // FIXME: This diagnostic should include the origin of the kernel
         // FIXME: names; not just the locations of the conflicting declarations.
-        Diag(FD->getLocation(), diag::err_sycl_kernel_name_conflict);
+        Diag(FD->getLocation(), diag::err_sycl_kernel_name_conflict)
+            << SKEPAttr;
         Diag(SKI->getKernelEntryPointDecl()->getLocation(),
              diag::note_previous_declaration);
         SKEPAttr->setInvalidAttr();
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index bd84a9741d01b..cdaf38dec916d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1147,7 +1147,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
     const SYCLKernelInfo *SKI = C.findSYCLKernelInfo(SKEPAttr->getKernelName());
     if (SKI) {
       if (!declaresSameEntity(FD, SKI->getKernelEntryPointDecl())) {
-        Reader.Diag(FD->getLocation(), diag::err_sycl_kernel_name_conflict);
+        Reader.Diag(FD->getLocation(), diag::err_sycl_kernel_name_conflict)
+            << SKEPAttr;
         Reader.Diag(SKI->getKernelEntryPointDecl()->getLocation(),
                     diag::note_previous_declaration);
         SKEPAttr->setInvalidAttr();
diff --git a/clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp b/clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp
index b112e9e1db850..1a82bdc1f5698 100644
--- a/clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp
+++ b/clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp
@@ -28,21 +28,21 @@
 // A unique kernel name type is required for each declared kernel entry point.
 template<int, int=0> struct KN;
 
-__attribute__((sycl_kernel_entry_point(KN<1>)))
+[[clang::sycl_kernel_entry_point(KN<1>)]]
 void skep1() {
 }
 // CHECK:      |-FunctionDecl {{.*}} skep1 'void ()'
 // CHECK:      | `-SYCLKernelEntryPointAttr {{.*}} KN<1>
 
 using KN2 = KN<2>;
-__attribute__((sycl_kernel_entry_point(KN2)))
+[[clang::sycl_kernel_entry_point(KN2)]]
 void skep2() {
 }
 // CHECK:      |-FunctionDecl {{.*}} skep2 'void ()'
 // CHECK:      | `-SYCLKernelEntryPointAttr {{.*}} KN2
 
 template<int I> using KNT = KN<I>;
-__attribute__((sycl_kernel_entry_point(KNT<3>)))
+[[clang::sycl_kernel_entry_point(KNT<3>)]]
 void skep3() {
 }
 // CHECK:      |-FunctionDecl {{.*}} skep3 'void ()'
diff --git a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp
index 872a44d80bf56..4774c8ef545f8 100644
--- a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp
+++ b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-appertainment.cpp
@@ -43,10 +43,11 @@ template<int, int = 0> struct KN;
 ////////////////////////////////////////////////////////////////////////////////
 
 // Function declaration with GNU attribute spelling
+// expected-warning at +1 {{unknown attribute 'sycl_kernel_entry_point' ignored}}
 __attribute__((sycl_kernel_entry_point(KN<1>)))
 void ok1();
 
-// Function declaration with Clang attribute spelling.
+// Function declaration with C++11 attribute spelling.
 [[clang::sycl_kernel_entry_point(KN<2>)]]
 void ok2();
 
@@ -142,7 +143,7 @@ struct S15 {
 // on occassion), main() still can't function as a SYCL kernel entry point,
 // so this test ensures such attempted uses of the attribute are rejected.
 struct Smain;
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute only applies to functions with a 'void' return type}}
+// expected-error at +1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions with a 'void' return type}}
 [[clang::sycl_kernel_entry_point(Smain)]]
 int main();
 
@@ -164,7 +165,7 @@ struct B2 {
 
 struct B3 {
   // Non-static member function declaration.
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
   [[clang::sycl_kernel_entry_point(BADKN<3>)]]
   void bad3();
 };
@@ -210,14 +211,14 @@ enum {
 };
 
 // Attribute added after the definition.
-// expected-error at +3 {{'sycl_kernel_entry_point' attribute cannot be added to a function after the function is defined}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' attribute cannot be added to a function after the function is defined}}
 // expected-note at +1 {{previous definition is here}}
 void bad15() {}
 [[clang::sycl_kernel_entry_point(BADKN<15>)]]
 void bad15();
 
 // The function must return void.
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute only applies to functions with a 'void' return type}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute only applies to functions with a 'void' return type}}
 [[clang::sycl_kernel_entry_point(BADKN<16>)]]
 int bad16();
 
@@ -230,12 +231,12 @@ void bad17(void (fp [[clang::sycl_kernel_entry_point(BADKN<17>)]])());
 // FIXME: and the C++ standard is unclear regarding whether such attributes are
 // FIXME: permitted. P3324 (Attributes for namespace aliases, template
 // FIXME: parameters, and lambda captures) seeks to clarify the situation.
-// FIXME-expected-error at +1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
+// FIXME-expected-error at +1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
 template<void (fp [[clang::sycl_kernel_entry_point(BADKN<18>)]])()>
 void bad18();
 
 #if __cplusplus >= 202002L
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
 [[clang::sycl_kernel_entry_point(BADKN<19>)]]
 void bad19() {
   co_return;
@@ -243,36 +244,36 @@ void bad19() {
 #endif
 
 struct B20 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
   [[clang::sycl_kernel_entry_point(BADKN<20>)]]
   B20();
 };
 
 struct B21 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
   [[clang::sycl_kernel_entry_point(BADKN<21>)]]
   ~B21();
 };
 
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a variadic function}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a variadic function}}
 [[clang::sycl_kernel_entry_point(BADKN<22>)]]
 void bad22(...);
 
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a deleted function}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a deleted function}}
 [[clang::sycl_kernel_entry_point(BADKN<23>)]]
 void bad23() = delete;
 
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a constexpr function}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a constexpr function}}
 [[clang::sycl_kernel_entry_point(BADKN<24>)]]
 constexpr void bad24() {}
 
 #if __cplusplus >= 202002L
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a consteval function}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a consteval function}}
 [[clang::sycl_kernel_entry_point(BADKN<25>)]]
 consteval void bad25() {}
 #endif
 
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a function declared with the 'noreturn' attribute}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a function declared with the 'noreturn' attribute}}
 [[clang::sycl_kernel_entry_point(BADKN<26>)]]
 [[noreturn]] void bad26();
 
@@ -283,7 +284,7 @@ __attribute__((target("sse4.2"))) void bad27();
 
 template<typename KNT>
 struct B28 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a deleted function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a deleted function}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend void bad28() = delete;
 };
@@ -291,7 +292,7 @@ struct B28 {
 #if __cplusplus >= 202002L
 template<typename KNT, typename T>
 struct B29 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a defaulted function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a defaulted function}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend T operator==(B29, B29) = default;
 };
@@ -300,7 +301,7 @@ struct B29 {
 #if __cplusplus >= 202002L
 template<typename KNT>
 struct B30 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend void bad30() { co_return; }
 };
@@ -308,14 +309,14 @@ struct B30 {
 
 template<typename KNT>
 struct B31 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a variadic function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a variadic function}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend void bad31(...) {}
 };
 
 template<typename KNT>
 struct B32 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a constexpr function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a constexpr function}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend constexpr void bad32() {}
 };
@@ -323,7 +324,7 @@ struct B32 {
 #if __cplusplus >= 202002L
 template<typename KNT>
 struct B33 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a consteval function}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a consteval function}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   friend consteval void bad33() {}
 };
@@ -331,31 +332,31 @@ struct B33 {
 
 template<typename KNT>
 struct B34 {
-  // expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a function declared with the 'noreturn' attribute}}
+  // expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a function declared with the 'noreturn' attribute}}
   [[clang::sycl_kernel_entry_point(KNT)]]
   [[noreturn]] friend void bad34() {}
 };
 
 #if __cplusplus >= 202302L
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a non-static member function}}
 auto bad35 = [] [[clang::sycl_kernel_entry_point(BADKN<35>)]] -> void {};
 #endif
 
 #if __cplusplus >= 202302L
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute only applies to functions with a non-deduced 'void' return type}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute only applies to functions with a non-deduced 'void' return type}}
 auto bad36 = [] [[clang::sycl_kernel_entry_point(BADKN<36>)]] static {};
 #endif
 
 #if __cplusplus >= 202302L
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a coroutine}}
 auto bad37 = [] [[clang::sycl_kernel_entry_point(BADKN<37>)]] static -> void { co_return; };
 #endif
 
-// expected-error at +1 {{'sycl_kernel_entry_point' attribute cannot be applied to a function defined with a function try block}}
+// expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a function defined with a function try block}}
 [[clang::sycl_kernel_entry_point(BADKN<38>)]]
 void bad38() try {} catch(...) {}
 
-// expected-error at +2 {{'sycl_kernel_entry_point' attribute cannot be applied to a function defined with a function try block}}
+// expected-error at +2 {{the 'clang::sycl_kernel_entry_point' attribute cannot be applied to a function defined with a function try block}}
 template<typename>
 [[clang::sycl_kernel_entry_point(BADKN<39>)]]
 void bad39() try {} catch(...) {}
diff --git a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp
index 83c3e5ca267ab..8788e147a2ae4 100644
--- a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp
+++ b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp
@@ -71,29 +71,29 @@ template void m2_test8<KN<8>>();
 #include "m2.h"
 
 // Expected diagnostics for m1_test3() and m2_test3():
-// expected-error at m2.h:4 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at m2.h:4 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m1.h:12 {{previous declaration is here}}
 
 // Expected diagnostics for m1_test4<KN<4>>() and m2_test4<KN<4>>():
-// expected-error at m2.h:8 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at m2.h:8 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m1.h:16 {{previous declaration is here}}
 
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m1.h:4 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<5>)]]
 void test5() {}
 
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m1.h:8 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<6>)]]
 void test6() {}
 
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m2.h:12 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<7>)]]
 void test7() {}
 
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at m2.h:16 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<8>)]]
 void test8() {}
diff --git a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
index 0814d898d1c0e..0575a7a5a67eb 100644
--- a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
+++ b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-pch.cpp
@@ -25,12 +25,12 @@ template void pch_test2<KN<2>>();
 
 
 #--- test.cpp
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at pch.h:4 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<1>)]]
 void test1() {}
 
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at pch.h:8 {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(KN<2>)]]
 void test2() {}
diff --git a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp
index 78dd89696c02d..c7b83932fefe6 100644
--- a/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp
+++ b/clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name.cpp
@@ -7,7 +7,7 @@
 // specification.
 
 struct S1;
-// expected-warning at +3 {{redundant 'sycl_kernel_entry_point' attribute}}
+// expected-warning at +3 {{redundant 'clang::sycl_kernel_entry_point' attribute}}
 // expected-note at +1  {{previous attribute is here}}
 [[clang::sycl_kernel_entry_point(S1),
   clang::sycl_kernel_entry_point(S1)]]
@@ -46,13 +46,13 @@ enum E9 : int; // #E9-decl
 struct B10 {
   struct MS;
 };
-// FIXME-expected-error at +1 {{'sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
+// FIXME-expected-error at +1 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
 [[clang::sycl_kernel_entry_point(B10::MS)]] void bad10();
 
 struct B11 {
   struct MS;
 };
-// FIXME-expected-error at +3 {{'sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
+// FIXME-expected-error at +3 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
 template<typename T>
 [[clang::sycl_kernel_entry_point(typename T::MS)]] void bad11() {}
 template void bad11<B11>();
@@ -60,35 +60,35 @@ template void bad11<B11>();
 template<typename T>
 [[clang::sycl_kernel_entry_point(T)]] void bad12();
 void f12() {
-  // FIXME-expected-error at +2 {{'sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
+  // FIXME-expected-error at +2 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
   struct LS;
   bad12<LS>();
 }
 
 struct B13_1;
 struct B13_2;
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B13_2' vs 'B13_1'}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B13_2' vs 'B13_1'}}
 // expected-note at +1  {{'bad13' declared here}}
 [[clang::sycl_kernel_entry_point(B13_1)]] void bad13();
 [[clang::sycl_kernel_entry_point(B13_2)]] void bad13() {}
 
 struct B14_1;
 struct B14_2;
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B14_2' vs 'B14_1'}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B14_2' vs 'B14_1'}}
 // expected-note at +1  {{previous attribute is here}}
 [[clang::sycl_kernel_entry_point(B14_1),
   clang::sycl_kernel_entry_point(B14_2)]]
 void bad14();
 
 struct B15;
-// expected-error at +3 {{'sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
+// expected-error at +3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
 // expected-note at +1  {{previous declaration is here}}
 [[clang::sycl_kernel_entry_point(B15)]] void bad15_1();
 [[clang::sycl_kernel_entry_point(B15)]] void bad15_2();
 
 struct B16_1;
 struct B16_2;
-// expected-error at +4 {{'sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B16_2' vs 'B16_1'}}
+// expected-error at +4 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B16_2' vs 'B16_1'}}
 // expected-note at +1  {{'bad16' declared here}}
 [[clang::sycl_kernel_entry_point(B16_1)]] void bad16();
 void bad16(); // The attribute from the previous declaration is inherited.

>From adcd6f88d7a7c3a3087419954ccefbff8747baae Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom.honermann at intel.com>
Date: Thu, 31 Jul 2025 14:00:56 -0700
Subject: [PATCH 2/2] Fix clang-format issues.

---
 clang/lib/Sema/SemaDecl.cpp | 2 +-
 clang/lib/Sema/SemaSYCL.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c6a586ad5f53a..d255c117129d9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3064,7 +3064,7 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
       // the semantic effects of the attribute having been applied.
       S.Diag(NewAttribute->getLocation(),
              diag::err_sycl_entry_point_after_definition)
-                 << NewAttribute;
+          << NewAttribute;
       S.Diag(Def->getLocation(), diag::note_previous_definition);
       cast<SYCLKernelEntryPointAttr>(NewAttribute)->setInvalidAttr();
       ++I;
diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index 3bd20aaf19b0d..4683c81bd1c60 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -268,7 +268,7 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
     } else {
       Diag(SAI->getLocation(),
            diag::warn_sycl_entry_point_redundant_declaration)
-               << SAI;
+          << SAI;
       Diag(SKEPAttr->getLocation(), diag::note_previous_attribute);
     }
   }
@@ -341,7 +341,7 @@ void SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
   if (FD->getReturnType()->isUndeducedType()) {
     Diag(SKEPAttr->getLocation(),
          diag::err_sycl_entry_point_deduced_return_type)
-             << SKEPAttr;
+        << SKEPAttr;
     SKEPAttr->setInvalidAttr();
   } else if (!FD->getReturnType()->isDependentType() &&
              !FD->getReturnType()->isVoidType()) {



More information about the cfe-commits mailing list