Skip to content

Commit 0d2dab4

Browse files
premanandraobader
authored andcommitted
[SYCL] Suppress warning about cdecl calling convention
Signed-off-by: Premanand M Rao <[email protected]>
1 parent d6023e8 commit 0d2dab4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,10 +4613,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
46134613
return true;
46144614
}
46154615

4616+
const TargetInfo &TI = Context.getTargetInfo();
46164617
// TODO: diagnose uses of these conventions on the wrong target.
46174618
switch (Attrs.getKind()) {
46184619
case ParsedAttr::AT_CDecl:
4619-
CC = CC_C;
4620+
CC = TI.getDefaultCallingConv();
46204621
break;
46214622
case ParsedAttr::AT_FastCall:
46224623
CC = CC_X86FastCall;
@@ -4681,7 +4682,6 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
46814682
}
46824683

46834684
TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
4684-
const TargetInfo &TI = Context.getTargetInfo();
46854685
// CUDA functions may have host and/or device attributes which indicate
46864686
// their targeted execution environment, therefore the calling convention
46874687
// of functions in CUDA should be checked against the target deduced based

clang/test/SemaSYCL/sycl-cconv.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
// RUN: %clang_cc1 -triple spir64-unknown-windows-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -fsyntax-only -verify %s
22

3-
//expected-warning@+1 {{'__cdecl' calling convention is not supported for this target}}
3+
// expected-no-warning@+1
44
__inline __cdecl int printf(char const* const _Format, ...) { return 0; }
5+
// expected-no-warning@+1
6+
__inline __cdecl __attribute__((sycl_device)) int foo() { return 0; }
7+
// expected-no-warning@+1
8+
__inline __cdecl int moo() { return 0; }
59

610
void bar() {
711
printf("hello\n"); // expected-no-error
812
}
913

1014
template <typename name, typename Func>
11-
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
15+
// expected-no-warning@+1
16+
__cdecl __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
17+
// expected-error@+1{{SYCL kernel cannot call a variadic function}}
18+
printf("cannot call from here\n");
19+
// expected-no-error@+1
20+
moo();
1221
kernelFunc();
1322
}
1423

0 commit comments

Comments
 (0)