diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index 0435c5aaba83..e90abe3a05f3 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -308,11 +308,12 @@ static void reportConflictingAttrs(Sema &S, FunctionDecl *F, const Attr *A1, F->setInvalidDecl(); } -// Returns the signed constant integer value represented by given expression. -static int64_t getIntExprValue(Sema &S, const Expr *E) { +/// Returns the signed constant integer value represented by given expression +static int64_t getIntExprValue(const Expr *E, ASTContext &Ctx) { llvm::APSInt Val(32); - bool IsValid = E->isIntegerConstantExpr(Val, S.getASTContext()); + bool IsValid = E->isIntegerConstantExpr(Val, Ctx); assert(IsValid && "expression must be constant integer"); + (void)IsValid; return Val.getSExtValue(); } @@ -1696,15 +1697,16 @@ void Sema::MarkDevice(void) { KernelBody ? KernelBody->getAttr() : nullptr; if (auto *Existing = SYCLKernel->getAttr()) { - if (Existing->getSubGroupSize() != Attr->getSubGroupSize()) { + if (getIntExprValue(Existing->getSubGroupSize(), getASTContext()) != + getIntExprValue(Attr->getSubGroupSize(), getASTContext())) { Diag(SYCLKernel->getLocation(), diag::err_conflicting_sycl_kernel_attributes); Diag(Existing->getLocation(), diag::note_conflicting_attribute); Diag(Attr->getLocation(), diag::note_conflicting_attribute); SYCLKernel->setInvalidDecl(); } - } else if (KBSimdAttr && - (getIntExprValue(*this, Attr->getSubGroupSize()) != 1)) { + } else if (KBSimdAttr && (getIntExprValue(Attr->getSubGroupSize(), + getASTContext()) != 1)) { reportConflictingAttrs(*this, KernelBody, KBSimdAttr, Attr); } else { SYCLKernel->addAttr(A); diff --git a/clang/test/SemaSYCL/reqd-sub-group-size-device.cpp b/clang/test/SemaSYCL/reqd-sub-group-size-device.cpp index 17e4735ce13d..aa61f8a9663c 100644 --- a/clang/test/SemaSYCL/reqd-sub-group-size-device.cpp +++ b/clang/test/SemaSYCL/reqd-sub-group-size-device.cpp @@ -45,7 +45,16 @@ void bar() { baz(); }); #endif + kernel([]() [[cl::intel_reqd_sub_group_size(2)]] { }); + kernel([]() [[cl::intel_reqd_sub_group_size(4)]] { foo(); }); +} + +[[cl::intel_reqd_sub_group_size(16)]] SYCL_EXTERNAL void B(); +[[cl::intel_reqd_sub_group_size(16)]] void A() { +} +[[cl::intel_reqd_sub_group_size(16)]] SYCL_EXTERNAL void B() { + A(); } #ifdef TRIGGER_ERROR