43 lines · plain
1// REQUIRES: x86-registered-target2// REQUIRES: nvptx-registered-target3// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \4// RUN: -verify -DEXPECT_VA_ARG_ERR %s5// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \6// RUN: -fcuda-allow-variadic-functions -verify -DEXPECT_VA_ARG_ERR %s7 8#include <stdarg.h>9#include "Inputs/cuda.h"10 11__global__ void foo() {12 va_list list;13 va_arg(list, int);14#ifdef EXPECT_VA_ARG_ERR15 // expected-error@-2 {{CUDA device code does not support va_arg}}16#endif17}18 19void bar() {20 va_list list;21 va_arg(list, int); // OK: host-only22}23 24__device__ void baz() {25#if !defined(__CUDA_ARCH__)26 va_list list;27 va_arg(list, int); // OK: only seen when compiling for host28#endif29}30 31__device__ void vararg(const char* x, ...) {} // OK32 33template <typename T>34__device__ void vararg(T t, ...) {} // OK35 36extern "C" __device__ int printf(const char* fmt, ...); // OK, special case.37 38extern "C" __device__ int printf(const char* fmt, ...) { return 0; } // OK39 40namespace ns {41__device__ int printf(const char* fmt, ...); // OK42}43