brintos

brintos / llvm-project-archived public Read only

0
0
Text · 766 B · 935fa50 Raw
33 lines · plain
1// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify -Wno-vla %s2// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -DHOST -Wno-vla %s3 4#ifndef __CUDA_ARCH__5// expected-no-diagnostics6#endif7 8#include "Inputs/cuda.h"9 10void 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#endif19}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#endif26}27 28// No error because never codegen'ed for device.29__host__ __device__ inline void hd_inline(int n) {30  int x[n];31}32void call_hd_inline() { hd_inline(42); }33