summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-10-08 22:15:58 +0000
committerJustin Lebar <jlebar@google.com>2016-10-08 22:15:58 +0000
commit985220f468a1bc5f8fd9ffd283427b8a486ec2bf (patch)
treea7f28d04a88c2819852a2bbd6fba0179c97a97f3 /test/PCH
parente5f86e2485e267ae93fa7e5139fc1c8c3c22335e (diff)
[CUDA] Add #pragma clang force_cuda_host_device_{begin,end} pragmas.
Summary: These cause us to consider all functions in-between to be __host__ __device__. You can nest these pragmas; you just can't have more 'end's than 'begin's. Reviewers: rsmith Subscribers: tra, jhen, cfe-commits Differential Revision: https://reviews.llvm.org/D24975 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/pragma-cuda-force-host-device.cu27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/PCH/pragma-cuda-force-host-device.cu b/test/PCH/pragma-cuda-force-host-device.cu
new file mode 100644
index 0000000000..dc006be960
--- /dev/null
+++ b/test/PCH/pragma-cuda-force-host-device.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-pch %s -o %t
+// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -include-pch %t -S -o /dev/null %s
+
+#ifndef HEADER
+#define HEADER
+
+#pragma clang force_cuda_host_device begin
+#pragma clang force_cuda_host_device begin
+#pragma clang force_cuda_host_device end
+
+void hd1() {}
+
+#else
+
+void hd2() {}
+
+#pragma clang force_cuda_host_device end
+
+void host_only() {}
+
+__attribute__((device)) void device() {
+ hd1();
+ hd2();
+ host_only(); // expected-error {{no matching function for call}}
+}
+
+#endif