| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
#include "Inputs/cuda.h" |
| 5 |
|
| 6 |
__device__ void operator delete(void *p) {} |
| 7 |
|
| 8 |
class A { |
| 9 |
int x; |
| 10 |
public: |
| 11 |
A() { |
| 12 |
x = 123; |
| 13 |
} |
| 14 |
}; |
| 15 |
|
| 16 |
template<class T> |
| 17 |
class shared_ptr { |
| 18 |
T *ptr; |
| 19 |
public: |
| 20 |
shared_ptr(T *p) { |
| 21 |
ptr = p; |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
// The constructor of B calls the delete operator to clean up |
| 26 |
// the memory allocated by the new operator when exceptions happen. |
| 27 |
// Make sure that there are no diagnostics due to the device delete |
| 28 |
// operator is used. |
| 29 |
// |
| 30 |
// No need to do similar checks on the device side since it does |
| 31 |
// not support exception. |
| 32 |
struct B{ |
| 33 |
shared_ptr<A> pa{new A}; |
| 34 |
}; |
| 35 |
|
| 36 |
int main() { |
| 37 |
B b; |
| 38 |
} |