comparison clang/test/SemaCUDA/overloaded-delete.cu @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
comparison
equal deleted inserted replaced
147:c2174574ed3a 150:1d019706d866
1 // expected-no-diagnostics
2
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
5
6 #include "Inputs/cuda.h"
7
8 struct S {
9 __host__ static void operator delete(void*, size_t) {}
10 __device__ static void operator delete(void*, size_t) {}
11 };
12
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.
16 delete s;
17 }
18
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.
23 ::delete ptr;
24 }
25
26 __device__ void test_default_global_delete(int *ptr) {
27 // Again, there should be no ambiguity between which operator delete we call.
28 ::delete ptr;
29 }
30 __host__ void test_default_global_delete(int *ptr) {
31 // Again, there should be no ambiguity between which operator delete we call.
32 ::delete ptr;
33 }
34
35 // It should work with only some of allocators (re-)declared.
36 __device__ void operator delete(void *ptr);
37
38 __host__ __device__ void test_partial_global_delete_hd(int *ptr) {
39 // Again, there should be no ambiguity between which operator delete we call.
40 ::delete ptr;
41 }
42
43 __device__ void test_partial_global_delete(int *ptr) {
44 // Again, there should be no ambiguity between which operator delete we call.
45 ::delete ptr;
46 }
47 __host__ void test_partial_global_delete(int *ptr) {
48 // Again, there should be no ambiguity between which operator delete we call.
49 ::delete ptr;
50 }
51
52
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) {}
56
57 __host__ __device__ void test_overloaded_global_delete_hd(int *ptr) {
58 // Again, there should be no ambiguity between which operator delete we call.
59 ::delete ptr;
60 }
61
62 __device__ void test_overloaded_global_delete(int *ptr) {
63 // Again, there should be no ambiguity between which operator delete we call.
64 ::delete ptr;
65 }
66 __host__ void test_overloaded_global_delete(int *ptr) {
67 // Again, there should be no ambiguity between which operator delete we call.
68 ::delete ptr;
69 }