1 // RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \
2 // RUN: -emit-llvm -o /dev/null -verify=device
3 // RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown \
4 // RUN: -emit-llvm -o /dev/null -verify=host
5 // RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown -fcuda-is-device \
6 // RUN: -emit-llvm -o /dev/null -verify=device
7 // RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown \
8 // RUN: -emit-llvm -o /dev/null -verify=host
9
10 #include "Inputs/cuda.h"
11 extern __host__ void host_fn();
12 extern __device__ void dev_fn();
13 extern __host__ __device__ void hd_fn();
14
15 struct H1D1 {
operator deleteH1D116 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1D117 __device__ void operator delete(void *) { dev_fn(); };
18 };
19
20 struct h1D1 {
21 __host__ void operator delete(void *) = delete;
22 // host-note@-1 {{'operator delete' has been explicitly marked deleted here}}
operator deleteh1D123 __device__ void operator delete(void *) { dev_fn(); };
24 };
25
26 struct H1d1 {
operator deleteH1d127 __host__ void operator delete(void *) { host_fn(); };
28 __device__ void operator delete(void *) = delete;
29 // device-note@-1 {{'operator delete' has been explicitly marked deleted here}}
30 };
31
32 struct H1D2 {
operator deleteH1D233 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1D234 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
35 };
36
37 struct H2D1 {
operator deleteH2D138 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
operator deleteH2D139 __device__ void operator delete(void *) { dev_fn(); };
40 };
41
42 struct H2D2 {
operator deleteH2D243 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
operator deleteH2D244 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
45 };
46
47 struct H1D1D2 {
operator deleteH1D1D248 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1D1D249 __device__ void operator delete(void *) { dev_fn(); };
operator deleteH1D1D250 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
51 };
52
53 struct H1H2D1 {
operator deleteH1H2D154 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1H2D155 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
operator deleteH1H2D156 __device__ void operator delete(void *) { dev_fn(); };
57 };
58
59 struct H1H2D2 {
operator deleteH1H2D260 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1H2D261 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
operator deleteH1H2D262 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
63 };
64
65 struct H1H2D1D2 {
operator deleteH1H2D1D266 __host__ void operator delete(void *) { host_fn(); };
operator deleteH1H2D1D267 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
operator deleteH1H2D1D268 __device__ void operator delete(void *) { dev_fn(); };
operator deleteH1H2D1D269 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
70 };
71
72
73 template <typename T>
test_hd(void * p)74 __host__ __device__ void test_hd(void *p) {
75 T *t = (T *)p;
76 delete t;
77 // host-error@-1 {{attempt to use a deleted function}}
78 // device-error@-2 {{attempt to use a deleted function}}
79 }
80
tests_hd(void * t)81 __host__ __device__ void tests_hd(void *t) {
82 test_hd<H1D1>(t);
83 test_hd<h1D1>(t);
84 // host-note@-1 {{in instantiation of function template specialization 'test_hd<h1D1>' requested here}}
85 test_hd<H1d1>(t);
86 // device-note@-1 {{in instantiation of function template specialization 'test_hd<H1d1>' requested here}}
87 test_hd<H1D2>(t);
88 test_hd<H2D1>(t);
89 test_hd<H2D2>(t);
90 test_hd<H1D1D2>(t);
91 test_hd<H1H2D1>(t);
92 test_hd<H1H2D1>(t);
93 test_hd<H1H2D2>(t);
94 test_hd<H1H2D1D2>(t);
95 }
96