1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
4 // RUN: %clang_cc1 -triple nvptx -fcuda-is-device -std=c++11 \
5 // RUN: -o - %s -fsyntax-only -verify=dev,com
7 // RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
8 // RUN: -o - %s -fsyntax-only -verify=host,com
10 // Checks allowed usage of file-scope and function-scope static variables.
12 #include "Inputs/cuda.h"
14 // Checks static variables are allowed in device functions.
16 __device__ void f1() {
17 const static int b = 123;
21 // Checks static variables are allowd in global functions.
23 __global__ void k1() {
24 const static int b = 123;
28 // Checks static device and constant variables are allowed in device and
29 // host functions, and static host variables are not allowed in device
32 static __device__ int x;
33 static __constant__ int y;
34 static int z; // dev-note {{host variable declared here}}
36 __global__ void kernel(int *a) {
40 // dev-error@-1 {{reference to __host__ variable 'z' in __global__ function}}
43 // Check dynamic initialization of static device variable is not allowed.
45 namespace TestStaticVarInLambda {
57 static __device__ B var2(c);
58 // com-error@-1 {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
65 int* getDeviceSymbol(int *x);