usual-deallocators.cu
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \
// RUN: -emit-llvm -o /dev/null -verify=device
// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown \
// RUN: -emit-llvm -o /dev/null -verify=host
// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown -fcuda-is-device \
// RUN: -emit-llvm -o /dev/null -verify=device
// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown \
// RUN: -emit-llvm -o /dev/null -verify=host
#include "Inputs/cuda.h"
extern __host__ void host_fn();
extern __device__ void dev_fn();
extern __host__ __device__ void hd_fn();
struct H1D1 {
__host__ void operator delete(void *) { host_fn(); };
__device__ void operator delete(void *) { dev_fn(); };
};
struct h1D1 {
__host__ void operator delete(void *) = delete;
// host-note@-1 {{'operator delete' has been explicitly marked deleted here}}
__device__ void operator delete(void *) { dev_fn(); };
};
struct H1d1 {
__host__ void operator delete(void *) { host_fn(); };
__device__ void operator delete(void *) = delete;
// device-note@-1 {{'operator delete' has been explicitly marked deleted here}}
};
struct H1D2 {
__host__ void operator delete(void *) { host_fn(); };
__device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
};
struct H2D1 {
__host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
__device__ void operator delete(void *) { dev_fn(); };
};
struct H2D2 {
__host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
__device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
};
struct H1D1D2 {
__host__ void operator delete(void *) { host_fn(); };
__device__ void operator delete(void *) { dev_fn(); };
__device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
};
struct H1H2D1 {
__host__ void operator delete(void *) { host_fn(); };
__host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
__device__ void operator delete(void *) { dev_fn(); };
};
struct H1H2D2 {
__host__ void operator delete(void *) { host_fn(); };
__host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
__device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
};
struct H1H2D1D2 {
__host__ void operator delete(void *) { host_fn(); };
__host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
__device__ void operator delete(void *) { dev_fn(); };
__device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
};
template <typename T>
__host__ __device__ void test_hd(void *p) {
T *t = (T *)p;
delete t;
// host-error@-1 {{attempt to use a deleted function}}
// device-error@-2 {{attempt to use a deleted function}}
}
__host__ __device__ void tests_hd(void *t) {
test_hd<H1D1>(t);
test_hd<h1D1>(t);
// host-note@-1 {{in instantiation of function template specialization 'test_hd<h1D1>' requested here}}
test_hd<H1d1>(t);
// device-note@-1 {{in instantiation of function template specialization 'test_hd<H1d1>' requested here}}
test_hd<H1D2>(t);
test_hd<H2D1>(t);
test_hd<H2D2>(t);
test_hd<H1D1D2>(t);
test_hd<H1H2D1>(t);
test_hd<H1H2D1>(t);
test_hd<H1H2D2>(t);
test_hd<H1H2D1D2>(t);
}