================
@@ -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());
+ if (LaunchIdExpr.isInvalid()) {
+ // Do not mark 'FD' as invalid. 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.
+ }
----------------
tahonermann wrote:
I agree it is a bit odd. I wrote it this way because the absence of a check
would be somewhat suspicious, so I wanted to clearly communicate that it has
been considered and handled (by not doing anything about it here). I haven't
manged to find a comment-only change that I'm fond of. Is this an improvement?
```suggestion
// 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.
```
https://github.com/llvm/llvm-project/pull/152403
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits