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
10 #include "Inputs/cuda.h"
11 extern __host__ void host_fn();
12 extern __device__ void dev_fn();
13 extern __host__ __device__ void hd_fn();
16 __host__ void operator delete(void *) { host_fn(); };
17 __device__ void operator delete(void *) { dev_fn(); };
21 __host__ void operator delete(void *) = delete;
22 // host-note@-1 {{'operator delete' has been explicitly marked deleted here}}
23 __device__ void operator delete(void *) { dev_fn(); };
27 __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}}
33 __host__ void operator delete(void *) { host_fn(); };
34 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
38 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
39 __device__ void operator delete(void *) { dev_fn(); };
43 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
44 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
48 __host__ void operator delete(void *) { host_fn(); };
49 __device__ void operator delete(void *) { dev_fn(); };
50 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
54 __host__ void operator delete(void *) { host_fn(); };
55 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
56 __device__ void operator delete(void *) { dev_fn(); };
60 __host__ void operator delete(void *) { host_fn(); };
61 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
62 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
66 __host__ void operator delete(void *) { host_fn(); };
67 __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); };
68 __device__ void operator delete(void *) { dev_fn(); };
69 __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); };
74 __host__ __device__ void test_hd(void *p) {
77 // host-error@-1 {{attempt to use a deleted function}}
78 // device-error@-2 {{attempt to use a deleted function}}
81 __host__ __device__ void tests_hd(void *t) {
84 // host-note@-1 {{in instantiation of function template specialization 'test_hd<h1D1>' requested here}}
86 // device-note@-1 {{in instantiation of function template specialization 'test_hd<H1d1>' requested here}}
97 // This should produce no errors. Defaulted destructor should be treated as HD,
98 // which allows referencing host-only `operator delete` with a deferred
99 // diagnostics that would fire if we ever attempt to codegen it on device..
101 virtual ~H() = default;
102 static void operator delete(void *) {}