llvm/clang/test/SemaCUDA/dependent-device-var.cu
Yaxun (Sam) Liu e355110040 [CUDA][HIP] Fix checking dependent initalizer
Defer constant checking of dependent initializer to template instantiation
since it cannot be done for dependent values.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D95840
2021-02-04 18:04:54 -05:00

19 lines
645 B
Plaintext

// RUN: %clang_cc1 -fsyntax-only -verify=host,com -x hip %s
// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify=dev,com -x hip %s
#include "Inputs/cuda.h"
template<typename T>
__device__ int fun1(T x) {
// Check type-dependent constant is allowed in initializer.
static __device__ int a = sizeof(x);
static __device__ int b = x;
// com-error@-1 {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
return a + b;
}
__device__ int fun1_caller() {
return fun1(1);
// com-note@-1 {{in instantiation of function template specialization 'fun1<int>' requested here}}
}