summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCUDA/implicit-device-lambda-hd.cu
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCUDA/implicit-device-lambda-hd.cu')
-rw-r--r--clang/test/SemaCUDA/implicit-device-lambda-hd.cu27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/SemaCUDA/implicit-device-lambda-hd.cu b/clang/test/SemaCUDA/implicit-device-lambda-hd.cu
new file mode 100644
index 00000000000..6cd0e96af8c
--- /dev/null
+++ b/clang/test/SemaCUDA/implicit-device-lambda-hd.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN: -S -o /dev/null %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note \
+// RUN: -DHOST -S -o /dev/null %s
+#include "Inputs/cuda.h"
+
+__host__ __device__ void hd_fn() {
+ auto f1 = [&] {};
+ f1(); // implicitly __host__ __device__
+
+ auto f2 = [&] __device__ {};
+ f2();
+#ifdef HOST
+ // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+ auto f3 = [&] __host__ {};
+ f3();
+#ifndef HOST
+ // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+ auto f4 = [&] __host__ __device__ {};
+ f4();
+}
+
+
OpenPOWER on IntegriCloud