================
@@ -16227,6 +16227,32 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope
*FnBodyScope, Decl *D,
maybeAddDeclWithEffects(FD);
+ if (FD && !FD->isInvalidDecl() && FD->hasAttr<SYCLKernelEntryPointAttr>() &&
+ FnBodyScope) {
+ // An implicit call expression is synthesized for functions declared with
+ // the sycl_kernel_entry_point attribute. The call may resolve to a
+ // function template, a member function template, or a call operator
+ // of a variable template depending on the results of unqualified lookup
+ // for 'sycl_kernel_launch' from the beginning of the function body.
+ // Performing that lookup requires the stack of parsing scopes active
+ // when the definition is parsed and is thus done here; the result is
+ // cached in FunctionScopeInfo and used to synthesize the (possibly
+ // unresolved) call expression after the function body has been parsed.
+ const auto *SKEPAttr = FD->getAttr<SYCLKernelEntryPointAttr>();
+ if (!SKEPAttr->isInvalidAttr()) {
+ ExprResult LaunchIdExpr =
+ SYCL().BuildSYCLKernelLaunchIdExpr(FD, SKEPAttr->getKernelName());
+ // Do not mark 'FD' as invalid if construction of `LaunchIDExpr` produces
+ // an invalid result. Name lookup failure for 'sycl_kernel_launch' is
+ // treated as an error in the definition of 'FD'; treating it as an error
+ // of the declaration would affect overload resolution which would
+ // potentially result in additional errors. If construction of
+ // 'LaunchIDExpr' failed, then 'SYCLKernelLaunchIdExpr' will be assigned
+ // a null pointer value below; that is expected.
+ getCurFunction()->SYCLKernelLaunchIdExpr = LaunchIdExpr.get();
----------------
AaronBallman wrote:
So if I understand correctly, a declaration with no definition is then not
diagnosed as an error despite the attribute being invalid, because we never get
a function definition?
https://github.com/llvm/llvm-project/pull/152403
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits