llvm-project
32 строки · 766.0 Байт
1// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify -Wno-vla %s
2// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -DHOST -Wno-vla %s
3
4#ifndef __CUDA_ARCH__
5// expected-no-diagnostics
6#endif
7
8#include "Inputs/cuda.h"
9
10void host(int n) {
11int x[n];
12}
13
14__device__ void device(int n) {
15int 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) {
22int 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) {
30int x[n];
31}
32void call_hd_inline() { hd_inline(42); }
33