Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,18 +1122,14 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) {

// The SYCL kernel's 'object type' used for diagnostics and naming/mangling is
// the first parameter to a function template using the sycl_kernel
// attribute. In SYCL 1.2.1, this was passed by value,
// and in SYCL 2020, it is passed by reference.
// attribute. In SYCL 2020, this is passed by reference.
static QualType GetSYCLKernelObjectType(const FunctionDecl *KernelCaller) {
assert(KernelCaller->getNumParams() > 0 && "Insufficient kernel parameters");
QualType KernelParamTy = KernelCaller->getParamDecl(0)->getType();

// SYCL 2020 kernels are passed by reference.
if (KernelParamTy->isReferenceType())
KernelParamTy = KernelParamTy->getPointeeType();

// SYCL 1.2.1
return KernelParamTy.getUnqualifiedType();
assert(KernelParamTy->isReferenceType() && "Since SYCL 2020 kernels must be passed by reference.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the assert message. I think you can just say kernel must be passed by reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it back. It seems like this assert gets hit before we issue a proper diagnostic for this kind of misuse.

return KernelParamTy = KernelParamTy->getPointeeType();
}

/// \return the target of given SYCL accessor type
Expand Down Expand Up @@ -5038,7 +5034,7 @@ void SemaSYCL::CheckSYCLKernelCall(FunctionDecl *KernelFunc,

// check that calling kernel conforms to spec
QualType KernelParamTy = KernelFunc->getParamDecl(0)->getType();
if (not KernelParamTy->isReferenceType()) {
if (! KernelParamTy->isReferenceType()) {
// passing by value. emit warning if using SYCL 2020 or greater
if (SemaRef.LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020)
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_value_deprecated);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we still have a diagnostic for deprecation for this case, you cannot assert in GetSYCLKernelObjectType

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to be an error. That said, even with it being an error, it is still checked later than the assert, so I am still on the side of no assertions.

Expand Down
Loading