diff options
| author | Artem Belevich <tra@google.com> | 2018-04-03 22:41:06 +0000 |
|---|---|---|
| committer | Artem Belevich <tra@google.com> | 2018-04-03 22:41:06 +0000 |
| commit | d9189d1e76dd0d2640b13b5c2aa4cfb47ea7d808 (patch) | |
| tree | febc074922b0206fcaeeeaafe4b78168f1a9349d /clang/test | |
| parent | 90f13ed0e42b17458bda8b1a350a68c53df9e6be (diff) | |
| download | bcm5719-llvm-d9189d1e76dd0d2640b13b5c2aa4cfb47ea7d808.tar.gz bcm5719-llvm-d9189d1e76dd0d2640b13b5c2aa4cfb47ea7d808.zip | |
[CUDA] Check initializers of instantiated template variables.
We were already performing checks on non-template variables,
but the checks on templated ones were missing.
Differential Revision: https://reviews.llvm.org/D45231
llvm-svn: 329127
Diffstat (limited to 'clang/test')
| -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}} +} |

