summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCUDA/implicit-device-lambda.cu
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCUDA/implicit-device-lambda.cu')
-rw-r--r--clang/test/SemaCUDA/implicit-device-lambda.cu20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/SemaCUDA/implicit-device-lambda.cu b/clang/test/SemaCUDA/implicit-device-lambda.cu
index be1babe8229..8e5b7ddddb8 100644
--- a/clang/test/SemaCUDA/implicit-device-lambda.cu
+++ b/clang/test/SemaCUDA/implicit-device-lambda.cu
@@ -76,6 +76,26 @@ __host__ void host_fn() {
f4();
}
+__host__ __device__ void hd_fn() {
+ auto f1 = [&] {};
+ f1(); // implicitly __host__ __device__
+
+ auto f2 = [&] __device__ {};
+ f2();
+#ifndef __CUDA_ARCH__
+ // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+ auto f3 = [&] __host__ {};
+ f3();
+#ifdef __CUDA_ARCH__
+ // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+ auto f4 = [&] __host__ __device__ {};
+ f4();
+}
+
// The special treatment above only applies to lambdas.
__device__ void foo() {
struct X {
OpenPOWER on IntegriCloud