Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ Bug Fixes to Attribute Support
- Using ``[[gnu::cleanup(some_func)]]`` where some_func is annotated with
``[[gnu::error("some error")]]`` now correctly triggers an error. (#GH146520)
- Fix a crash when the function name is empty in the `swift_name` attribute. (#GH157075)
- Fix a crash and missing diagnostic when using some device_kernel attributes in
unsupported targets. (#GH161077)

Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 6 additions & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5204,7 +5204,12 @@ static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
static void handleDeviceKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
bool IsFunctionTemplate = FD && FD->getDescribedFunctionTemplate();
if (S.getLangOpts().SYCLIsDevice) {
if (!S.getLangOpts().OpenCL && !S.getLangOpts().CUDA &&
Copy link
Member

Choose a reason for hiding this comment

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

I'm doing a test to see if we need the AMDGPU special casing, will post my results in the other PR. probably we should wait for that before moving forward with this

!DeviceKernelAttr::isAMDGPUSpelling(AL)) {
// This is already diagnosed for AMDGPU in getCCForDeclaratorChunk
S.Diag(AL.getLoc(), diag::warn_cconv_unsupported)
<< AL << (int)Sema::CallingConventionIgnoredReason::ForThisTarget;
} else if (S.getLangOpts().SYCLIsDevice) {
if (!IsFunctionTemplate) {
S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< AL << AL.isRegularKeywordAttribute() << "function templates";
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3780,7 +3780,7 @@ static CallingConv getCCForDeclaratorChunk(
}
}
}
if (!S.getLangOpts().isSYCL()) {
if (S.getLangOpts().OpenCL || S.getLangOpts().CUDA) {
for (const ParsedAttr &AL : D.getDeclSpec().getAttributes()) {
if (AL.getKind() == ParsedAttr::AT_DeviceKernel) {
CC = CC_DeviceKernel;
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Sema/callingconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ int __attribute__((aarch64_vector_pcs)) aavpcs(void); // expected-warning {{'aar
int __attribute__((aarch64_sve_pcs)) aasvepcs(void); // expected-warning {{'aarch64_sve_pcs' calling convention is not supported for this target}}

int __attribute__((amdgpu_kernel)) amdgpu_kernel(void); // expected-warning {{'amdgpu_kernel' calling convention is not supported for this target}}
int __attribute__((device_kernel)) device_kernel(void) { // expected-warning {{'device_kernel' calling convention is not supported for this target}}
Copy link
Member

@sarnex sarnex Oct 3, 2025

Choose a reason for hiding this comment

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

fyi i added this test in locally so once i get to PR-level we'll have a lock down for the crash

}
int __attribute__((sycl_kernel)) sycl_kernel(void) { // expected-warning {{'sycl_kernel' calling convention is not supported for this target}}
}

// PR6361
void ctest3();
Expand Down
Loading