summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-09-30 17:14:48 +0000
committerJustin Lebar <jlebar@google.com>2016-09-30 17:14:48 +0000
commit0fad0ba6a9b0e4900a6e247831c83f665bde2a6b (patch)
treee5e0c5e8e82343c08c01a1a578e26ffd3e3e2505 /clang/test/Parser
parentc5ed65ca3049e279e47692435111f30c09bbaa6b (diff)
downloadbcm5719-llvm-0fad0ba6a9b0e4900a6e247831c83f665bde2a6b.tar.gz
bcm5719-llvm-0fad0ba6a9b0e4900a6e247831c83f665bde2a6b.zip
[CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).
Summary: This is ugh, but it makes us compatible with NVCC. Fixes bug 26341. Reviewers: rnk Subscribers: cfe-commits, tra Differential Revision: https://reviews.llvm.org/D25103 llvm-svn: 282879
Diffstat (limited to 'clang/test/Parser')
-rw-r--r--clang/test/Parser/lambda-attr.cu33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/Parser/lambda-attr.cu b/clang/test/Parser/lambda-attr.cu
new file mode 100644
index 00000000000..c51e0a2b9d9
--- /dev/null
+++ b/clang/test/Parser/lambda-attr.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+ ([]() __attribute__((device)) { device_fn(); })();
+ ([] __attribute__((device)) () { device_fn(); })();
+ ([] __attribute__((device)) { device_fn(); })();
+
+ ([&]() __attribute__((device)){ device_fn(); })();
+ ([&] __attribute__((device)) () { device_fn(); })();
+ ([&] __attribute__((device)) { device_fn(); })();
+
+ ([&](int) __attribute__((device)){ device_fn(); })(0);
+ ([&] __attribute__((device)) (int) { device_fn(); })(0);
+}
+
+__attribute__((host)) __attribute__((device)) void host_device_attrs() {
+ ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+ ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+ ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+ ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+ ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+ ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+ ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+ ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
+}
OpenPOWER on IntegriCloud