150
|
1 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify %s
|
|
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -DHOST %s
|
|
3
|
|
4 #ifndef __CUDA_ARCH__
|
|
5 // expected-no-diagnostics
|
|
6 #endif
|
|
7
|
|
8 #include "Inputs/cuda.h"
|
|
9
|
|
10 void host(int n) {
|
|
11 int x[n];
|
|
12 }
|
|
13
|
|
14 __device__ void device(int n) {
|
|
15 int x[n];
|
|
16 #ifdef __CUDA_ARCH__
|
|
17 // expected-error@-2 {{cannot use variable-length arrays in __device__ functions}}
|
|
18 #endif
|
|
19 }
|
|
20
|
|
21 __host__ __device__ void hd(int n) {
|
|
22 int x[n];
|
|
23 #ifdef __CUDA_ARCH__
|
|
24 // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
|
|
25 #endif
|
|
26 }
|
|
27
|
|
28 // No error because never codegen'ed for device.
|
|
29 __host__ __device__ inline void hd_inline(int n) {
|
|
30 int x[n];
|
|
31 }
|
|
32 void call_hd_inline() { hd_inline(42); }
|