diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCUDA/Inputs/cuda.h | 4 | ||||
-rw-r--r-- | clang/test/SemaCUDA/call-host-fn-from-device.cu | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/clang/test/SemaCUDA/Inputs/cuda.h b/clang/test/SemaCUDA/Inputs/cuda.h index d0546704598..4544369411f 100644 --- a/clang/test/SemaCUDA/Inputs/cuda.h +++ b/clang/test/SemaCUDA/Inputs/cuda.h @@ -22,7 +22,9 @@ typedef struct cudaStream *cudaStream_t; int cudaConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0, cudaStream_t stream = 0); -// Device-side placement new overloads. +// Host- and device-side placement new overloads. +void *operator new(__SIZE_TYPE__, void *p) { return p; } +void *operator new[](__SIZE_TYPE__, void *p) { return p; } __device__ void *operator new(__SIZE_TYPE__, void *p) { return p; } __device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; } diff --git a/clang/test/SemaCUDA/call-host-fn-from-device.cu b/clang/test/SemaCUDA/call-host-fn-from-device.cu index 445188372f5..782c13d5445 100644 --- a/clang/test/SemaCUDA/call-host-fn-from-device.cu +++ b/clang/test/SemaCUDA/call-host-fn-from-device.cu @@ -12,6 +12,9 @@ extern "C" void host_fn() {} // expected-note@-4 {{'host_fn' declared here}} // expected-note@-5 {{'host_fn' declared here}} // expected-note@-6 {{'host_fn' declared here}} +// expected-note@-7 {{'host_fn' declared here}} + +struct Dummy {}; struct S { S() {} @@ -34,6 +37,15 @@ struct T { void h() {} // expected-note@-1 {{'h' declared here}} + + void operator+(); + // expected-note@-1 {{'operator+' declared here}} + + void operator-(const T&) {} + // expected-note@-1 {{'operator-' declared here}} + + operator Dummy() { return Dummy(); } + // expected-note@-1 {{'operator Dummy' declared here}} }; __host__ __device__ void T::hd3() { @@ -92,3 +104,30 @@ template <typename T> __host__ __device__ void fn_ptr_template() { auto* ptr = &host_fn; // Not an error because the template isn't instantiated. } + +__host__ __device__ void unaryOp() { + T t; + (void) +t; // expected-error {{reference to __host__ function 'operator+' in __host__ __device__ function}} +} + +__host__ __device__ void binaryOp() { + T t; + (void) (t - t); // expected-error {{reference to __host__ function 'operator-' in __host__ __device__ function}} +} + +__host__ __device__ void implicitConversion() { + T t; + Dummy d = t; // expected-error {{reference to __host__ function 'operator Dummy' in __host__ __device__ function}} +} + +template <typename T> +struct TmplStruct { + template <typename U> __host__ __device__ void fn() {} +}; + +template <> +template <> +__host__ __device__ void TmplStruct<int>::fn<int>() { host_fn(); } +// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}} + +__device__ void double_specialization() { TmplStruct<int>().fn<int>(); } |