================
@@ -202,6 +202,25 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr 
&AL) {
   handleSimpleAttribute<DeviceKernelAttr>(*this, D, AL);
 }
 
+void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) {
+  auto *FD = cast<FunctionDecl>(D);
+  if (!FD->isExternallyVisible()) {
+    Diag(AL.getLoc(), diag::err_sycl_attribute_invalid_linkage);
+    return;
+  }
+  std::string FunctionName = 
StringRef(FD->getNameInfo().getAsString()).lower();
+  if (FunctionName.find("main") != std::string::npos) {
+    Diag(AL.getLoc(), diag::err_sycl_attribute_avoid_main);
+    return;
+  }
+  if (FD->isDeleted()) {
+    Diag(AL.getLoc(), diag::err_sycl_attribute_avoid_deleted_function);
+    return;
+  }
----------------
tahonermann wrote:

I think this should call `isDeletedAsWritten()` so that it doesn't check for 
functions that are explicitly defaulted but defined as deleted. See additional 
test comments.

Also, I think this diagnostic would be better done in 
`Sema::CheckFunctionDeclaration()`; probably near the call to 
`CheckSYCLEntryPointFunctionDecl()`. Per my other comment, perhaps it makes 
sense to call a `CheckSYCLExternalFunctionDecl()` function there.

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