annotate clang/test/SemaCUDA/vararg.cu @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // REQUIRES: x86-registered-target
anatofuz
parents:
diff changeset
2 // REQUIRES: nvptx-registered-target
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
anatofuz
parents:
diff changeset
4 // RUN: -verify -DEXPECT_VA_ARG_ERR -DEXPECT_VARARG_ERR %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
anatofuz
parents:
diff changeset
6 // RUN: -fcuda-allow-variadic-functions -verify -DEXPECT_VA_ARG_ERR %s
anatofuz
parents:
diff changeset
7 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify \
anatofuz
parents:
diff changeset
8 // RUN: -DEXPECT_VARARG_ERR %s
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 #include <stdarg.h>
anatofuz
parents:
diff changeset
11 #include "Inputs/cuda.h"
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 __device__ void foo() {
anatofuz
parents:
diff changeset
14 va_list list;
anatofuz
parents:
diff changeset
15 va_arg(list, int);
anatofuz
parents:
diff changeset
16 #ifdef EXPECT_VA_ARG_ERR
anatofuz
parents:
diff changeset
17 // expected-error@-2 {{CUDA device code does not support va_arg}}
anatofuz
parents:
diff changeset
18 #endif
anatofuz
parents:
diff changeset
19 }
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 void bar() {
anatofuz
parents:
diff changeset
22 va_list list;
anatofuz
parents:
diff changeset
23 va_arg(list, int); // OK: host-only
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 __device__ void baz() {
anatofuz
parents:
diff changeset
27 #if !defined(__CUDA_ARCH__)
anatofuz
parents:
diff changeset
28 va_list list;
anatofuz
parents:
diff changeset
29 va_arg(list, int); // OK: only seen when compiling for host
anatofuz
parents:
diff changeset
30 #endif
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 __device__ void vararg(const char* x, ...) {}
anatofuz
parents:
diff changeset
34 #ifdef EXPECT_VARARG_ERR
anatofuz
parents:
diff changeset
35 // expected-error@-2 {{CUDA device code does not support variadic functions}}
anatofuz
parents:
diff changeset
36 #endif
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 template <typename T>
anatofuz
parents:
diff changeset
39 __device__ void vararg(T t, ...) {}
anatofuz
parents:
diff changeset
40 #ifdef EXPECT_VARARG_ERR
anatofuz
parents:
diff changeset
41 // expected-error@-2 {{CUDA device code does not support variadic functions}}
anatofuz
parents:
diff changeset
42 #endif
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 extern "C" __device__ int printf(const char* fmt, ...); // OK, special case.
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 // Definition of printf not allowed.
anatofuz
parents:
diff changeset
47 extern "C" __device__ int printf(const char* fmt, ...) { return 0; }
anatofuz
parents:
diff changeset
48 #ifdef EXPECT_VARARG_ERR
anatofuz
parents:
diff changeset
49 // expected-error@-2 {{CUDA device code does not support variadic functions}}
anatofuz
parents:
diff changeset
50 #endif
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 namespace ns {
anatofuz
parents:
diff changeset
53 __device__ int printf(const char* fmt, ...);
anatofuz
parents:
diff changeset
54 #ifdef EXPECT_VARARG_ERR
anatofuz
parents:
diff changeset
55 // expected-error@-2 {{CUDA device code does not support variadic functions}}
anatofuz
parents:
diff changeset
56 #endif
anatofuz
parents:
diff changeset
57 }