diff options
Diffstat (limited to 'clang/test/SemaCUDA')
-rw-r--r-- | clang/test/SemaCUDA/device-var-init.cu | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/SemaCUDA/device-var-init.cu b/clang/test/SemaCUDA/device-var-init.cu index 71f2352843b..46cb90da2ec 100644 --- a/clang/test/SemaCUDA/device-var-init.cu +++ b/clang/test/SemaCUDA/device-var-init.cu @@ -225,3 +225,20 @@ inline __host__ __device__ void hd_emitted_host_only() { static int x = 42; // no error on device because this is never codegen'ed there. } void call_hd_emitted_host_only() { hd_emitted_host_only(); } + +// Verify that we also check field initializers in instantiated structs. +struct NontrivialInitializer { + __host__ __device__ NontrivialInitializer() : x(43) {} + int x; +}; + +template <typename T> +__global__ void bar() { + __shared__ T bad; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +} + +void instantiate() { + bar<NontrivialInitializer><<<1, 1>>>(); +// expected-note@-1 {{in instantiation of function template specialization 'bar<NontrivialInitializer>' requested here}} +} |