blob: a5c8a6cd39487e89b9e1d637a00967aa2ebf3a3c [file] [log] [blame]
Artem Belevichfa62ad42015-04-27 19:37:53 +00001// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
2// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -verify -fcuda-is-device %s
Peter Collingbourne6ab610c2010-12-01 03:15:31 +00003
Eli Bendersky3468d9d2014-04-28 22:21:28 +00004#include "Inputs/cuda.h"
Peter Collingbourne6ab610c2010-12-01 03:15:31 +00005
Artem Belevichfa62ad42015-04-27 19:37:53 +00006// Host (x86) supports TLS and device-side compilation should ignore
7// host variables. No errors in either case.
8int __thread host_tls_var;
9
10#if defined(__CUDA_ARCH__)
11// NVPTX does not support TLS
12__device__ int __thread device_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
13__shared__ int __thread shared_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
14#else
15// Device-side vars should not produce any errors during host-side
16// compilation.
17__device__ int __thread device_tls_var;
18__shared__ int __thread shared_tls_var;
19#endif
20
Peter Collingbourne6ab610c2010-12-01 03:15:31 +000021__global__ void g1(int x) {}
Peter Collingbournee8cfaf42010-12-12 23:02:57 +000022__global__ int g2(int x) { // expected-error {{must have void return type}}
23 return 1;
24}