blob: 4be850586fbfdf2779367286b0ddd67af125b46e [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
Artem Belevicha0473a52015-04-28 20:31:49 +00003//
4// We run clang_cc1 with 'not' because source file contains
5// intentional errors. CC1 failure is expected and must be ignored
6// here. We're interested in what ends up in AST and that's what
7// FileCheck verifies.
8// RUN: not %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -ast-dump %s \
9// RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-HOST
10// RUN: not %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -ast-dump -fcuda-is-device %s \
11// RUN: | FileCheck %s --check-prefix=CHECK-ALL --check-prefix=CHECK-DEVICE
Peter Collingbourne6ab610c2010-12-01 03:15:31 +000012
Eli Bendersky3468d9d2014-04-28 22:21:28 +000013#include "Inputs/cuda.h"
Peter Collingbourne6ab610c2010-12-01 03:15:31 +000014
Artem Belevichfa62ad42015-04-27 19:37:53 +000015// Host (x86) supports TLS and device-side compilation should ignore
16// host variables. No errors in either case.
17int __thread host_tls_var;
Artem Belevicha0473a52015-04-28 20:31:49 +000018// CHECK-ALL: host_tls_var 'int' tls
Artem Belevichfa62ad42015-04-27 19:37:53 +000019
20#if defined(__CUDA_ARCH__)
21// NVPTX does not support TLS
22__device__ int __thread device_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
Artem Belevicha0473a52015-04-28 20:31:49 +000023// CHECK-DEVICE: device_tls_var 'int' tls
Artem Belevichfa62ad42015-04-27 19:37:53 +000024__shared__ int __thread shared_tls_var; // expected-error {{thread-local storage is not supported for the current target}}
Artem Belevicha0473a52015-04-28 20:31:49 +000025// CHECK-DEVICE: shared_tls_var 'int' tls
Artem Belevichfa62ad42015-04-27 19:37:53 +000026#else
27// Device-side vars should not produce any errors during host-side
28// compilation.
29__device__ int __thread device_tls_var;
Artem Belevicha0473a52015-04-28 20:31:49 +000030// CHECK-HOST: device_tls_var 'int' tls
Artem Belevichfa62ad42015-04-27 19:37:53 +000031__shared__ int __thread shared_tls_var;
Artem Belevicha0473a52015-04-28 20:31:49 +000032// CHECK-HOST: shared_tls_var 'int' tls
Artem Belevichfa62ad42015-04-27 19:37:53 +000033#endif
34
Peter Collingbourne6ab610c2010-12-01 03:15:31 +000035__global__ void g1(int x) {}
Peter Collingbournee8cfaf42010-12-12 23:02:57 +000036__global__ int g2(int x) { // expected-error {{must have void return type}}
37 return 1;
38}