1 // expected-no-diagnostics
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
6 #include "Inputs/cuda.h"
9 __host__ static void operator delete(void*, size_t) {}
10 __device__ static void operator delete(void*, size_t) {}
13 __host__ __device__ void test(S* s) {
14 // This shouldn't be ambiguous -- we call the host overload in host mode and
15 // the device overload in device mode.
19 // Code should work with no explicit declarations/definitions of
20 // allocator functions.
21 __host__ __device__ void test_default_global_delete_hd(int *ptr) {
22 // Again, there should be no ambiguity between which operator delete we call.
26 __device__ void test_default_global_delete(int *ptr) {
27 // Again, there should be no ambiguity between which operator delete we call.
30 __host__ void test_default_global_delete(int *ptr) {
31 // Again, there should be no ambiguity between which operator delete we call.
35 // It should work with only some of allocators (re-)declared.
36 __device__ void operator delete(void *ptr);
38 __host__ __device__ void test_partial_global_delete_hd(int *ptr) {
39 // Again, there should be no ambiguity between which operator delete we call.
43 __device__ void test_partial_global_delete(int *ptr) {
44 // Again, there should be no ambiguity between which operator delete we call.
47 __host__ void test_partial_global_delete(int *ptr) {
48 // Again, there should be no ambiguity between which operator delete we call.
53 // We should be able to define both host and device variants.
54 __host__ void operator delete(void *ptr) {}
55 __device__ void operator delete(void *ptr) {}
57 __host__ __device__ void test_overloaded_global_delete_hd(int *ptr) {
58 // Again, there should be no ambiguity between which operator delete we call.
62 __device__ void test_overloaded_global_delete(int *ptr) {
63 // Again, there should be no ambiguity between which operator delete we call.
66 __host__ void test_overloaded_global_delete(int *ptr) {
67 // Again, there should be no ambiguity between which operator delete we call.