================
@@ -15978,6 +15988,24 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
       CheckCoroutineWrapper(FD);
   }
 
+  // Diagnose invalid SYCL kernel entry point function declarations.
+  if (FD && !FD->isInvalidDecl() && !FD->isTemplated() &&
+      FD->hasAttr<SYCLKernelEntryPointAttr>()) {
+    if (FD->isDeleted()) {
+      Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
+           diag::err_sycl_entry_point_invalid)
+          << /*deleted function*/ 2;
+    } else if (FD->isDefaulted()) {
+      Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
+           diag::err_sycl_entry_point_invalid)
+          << /*defaulted function*/ 3;
+    } else if (FSI->isCoroutine()) {
+      Diag(FD->getAttr<SYCLKernelEntryPointAttr>()->getLocation(),
+           diag::err_sycl_entry_point_invalid)
+          << /*coroutine*/ 7;
----------------
tahonermann wrote:

Thanks for pointing me to those examples. For both `AttributeArgumentNType` and 
`AttributeDeclKind`, the production of the diagnostic is more complicated. For 
the first case, the diagnostic is produced in a lambda expression and the 
`%select` index is passed as an argument. For the second case, the `%select` 
index is computed by mapping from another enumeration using a switch statement. 
An enum definitely seems warranted for those cases. Similarly, for 
`Sema::checkTargetVersionAttr`, there are multiple `%select` indices involved 
in each diagnostic and the local enumeration does help with readability.

For simple diagnostics, where the `%select` index doesn't require computation 
and where the same index values are not used in multiple places, I think 
indirection through an enumeration isn't helpful, so I haven't made a change. 
If you still think a change is warranted, perhaps we can get a second opinion.

https://github.com/llvm/llvm-project/pull/120327
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to