[clang] [clang][SYCL] Handle cdecl variadic functions for SYCL device (PR #194922)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 21:22:36 PDT 2026


================
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -aux-triple x86_64-pc-windows-msvc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -isystem %S/Inputs/ -fsycl-is-device -triple spirv64 -fsyntax-only -verify %s
+
+// Check that there is no error/warning emitted for cdecl functions compiled for
+// SYCL device. Make sure variadic calls from within device code are diagnosed.
+
+__inline __cdecl int printf(char const* const _Format, ...) { return 0; }
+
+// FIXME: that should be diagnosed.
----------------
tahonermann wrote:

Curiously, SYCL 2020 states (in [section 5.4, "Language restrictions for device functions"](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:language.restrictions.kernels)), that "No variadic functions are allowed to be called in a device function". It doesn't appear to actually restrict declaring a variadic function though. So, I guess such declarations are fine so long as the function is never called from a device (it could still be called from host code) 🤷‍♂️ I think I agree a warning that the combination of `SYCL_EXTERNAL` and a variadic function doesn't make a lot of sense is warranted. I updated my own notes to add such a diagnostic eventually.

https://github.com/llvm/llvm-project/pull/194922


More information about the cfe-commits mailing list