1 // REQUIRES: x86-registered-target
2 // REQUIRES: nvptx-registered-target
3 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
4 // RUN: -verify -DEXPECT_VA_ARG_ERR -DEXPECT_VARARG_ERR %s
5 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
6 // RUN: -fcuda-allow-variadic-functions -verify -DEXPECT_VA_ARG_ERR %s
7 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify \
8 // RUN: -DEXPECT_VARARG_ERR %s
11 #include "Inputs/cuda.h"
13 __device__ void foo() {
16 #ifdef EXPECT_VA_ARG_ERR
17 // expected-error@-2 {{CUDA device code does not support va_arg}}
23 va_arg(list, int); // OK: host-only
26 __device__ void baz() {
27 #if !defined(__CUDA_ARCH__)
29 va_arg(list, int); // OK: only seen when compiling for host
33 __device__ void vararg(const char* x, ...) {}
34 #ifdef EXPECT_VARARG_ERR
35 // expected-error@-2 {{CUDA device code does not support variadic functions}}
39 __device__ void vararg(T t, ...) {}
40 #ifdef EXPECT_VARARG_ERR
41 // expected-error@-2 {{CUDA device code does not support variadic functions}}
44 extern "C" __device__ int printf(const char* fmt, ...); // OK, special case.
46 // Definition of printf not allowed.
47 extern "C" __device__ int printf(const char* fmt, ...) { return 0; }
48 #ifdef EXPECT_VARARG_ERR
49 // expected-error@-2 {{CUDA device code does not support variadic functions}}
53 __device__ int printf(const char* fmt, ...);
54 #ifdef EXPECT_VARARG_ERR
55 // expected-error@-2 {{CUDA device code does not support variadic functions}}