Justin Lebar | 4c2c6fd | 2016-07-12 23:23:12 +0000 | [diff] [blame^] | 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 | __host__ void operator delete(void *ptr) {} |
| 20 | __device__ void operator delete(void *ptr) {} |
| 21 | |
| 22 | __host__ __device__ void test_global_delete(int *ptr) { |
| 23 | // Again, there should be no ambiguity between which operator delete we call. |
| 24 | ::delete ptr; |
| 25 | } |