xref: /llvm-project/clang/test/SemaCUDA/dependent-device-var.cu (revision e355110040d17dcbf0fcfcba386c4d96fe6fe7ec)
1 // RUN: %clang_cc1 -fsyntax-only -verify=host,com -x hip %s
2 // RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify=dev,com -x hip %s
3 
4 #include "Inputs/cuda.h"
5 
6 template<typename T>
fun1(T x)7 __device__ int fun1(T x) {
8   // Check type-dependent constant is allowed in initializer.
9   static __device__ int a = sizeof(x);
10   static __device__ int b = x;
11   // com-error@-1 {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
12   return  a + b;
13 }
14 
fun1_caller()15 __device__ int fun1_caller() {
16   return fun1(1);
17   // com-note@-1 {{in instantiation of function template specialization 'fun1<int>' requested here}}
18 }
19