[clang] [SYCL] Basic diagnostics for the sycl_kernel_entry_point attribute. (PR #120327)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 11:15:50 PST 2024


================
@@ -1134,8 +1134,18 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   // the presence of a sycl_kernel_entry_point attribute, register it so that
   // associated metadata is recreated.
   if (FD->hasAttr<SYCLKernelEntryPointAttr>()) {
+    const auto *SKEPAttr = FD->getAttr<SYCLKernelEntryPointAttr>();
     ASTContext &C = Reader.getContext();
-    C.registerSYCLEntryPointFunction(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);
----------------
tahonermann wrote:

I don't know where else it could be checked. If you search for `.Diag` elsewhere in the file, you'll see checks for similar conditions; e.g., for duplicate definitions across modules in `checkMultipleDefinitionInNamedModules()` (as required by the C++ standard), for duplicate Objective-C instance variables in `VisitObjCIvarDecl()`, and for duplicate Objective-C category definitions in `ObjCCategoriesVisitor::add()`. I think this follows existing precedent.

https://github.com/llvm/llvm-project/pull/120327


More information about the cfe-commits mailing list