| 1 |
// RUN: %clang_cc1 -std=c++17 -triple nvptx64-nvidia-cuda -fsyntax-only \ |
| 2 |
// RUN: -fcuda-is-device -verify=expected,dev %s |
| 3 |
// RUN: %clang_cc1 -std=c++17 -triple nvptx64-nvidia-cuda -fsyntax-only \ |
| 4 |
// RUN: -verify %s |
| 5 |
|
| 6 |
#include "Inputs/cuda.h" |
| 7 |
|
| 8 |
template <class T> |
| 9 |
struct CTADType { // expected-note 2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 3 were provided}} |
| 10 |
// expected-note@-1 2{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 3 were provided}} |
| 11 |
T first; |
| 12 |
T second; |
| 13 |
|
| 14 |
CTADType(T x) : first(x), second(x) {} // expected-note 2{{candidate constructor not viable: requires single argument 'x', but 3 arguments were provided}} |
| 15 |
__device__ CTADType(T x) : first(x), second(x) {} // expected-note 2{{candidate constructor not viable: requires single argument 'x', but 3 arguments were provided}} |
| 16 |
__host__ __device__ CTADType(T x, T y) : first(x), second(y) {} // expected-note 2{{candidate constructor not viable: requires 2 arguments, but 3 were provided}} |
| 17 |
CTADType(T x, T y, T z) : first(x), second(z) {} // dev-note {{'CTADType' declared here}} |
| 18 |
// expected-note@-1 {{candidate constructor not viable: call to __host__ function from __device__ function}} |
| 19 |
// expected-note@-2 {{candidate constructor not viable: call to __host__ function from __global__ function}} |
| 20 |
}; |
| 21 |
|
| 22 |
template <class T> |
| 23 |
CTADType(T, T) -> CTADType<T>; |
| 24 |
|
| 25 |
__host__ __device__ void use_ctad_host_device() { |
| 26 |
CTADType ctad_from_two_args(1, 1); |
| 27 |
CTADType ctad_from_one_arg(1); |
| 28 |
CTADType ctad_from_three_args(1, 2, 3); // dev-error {{reference to __host__ function 'CTADType' in __host__ __device__ function}} |
| 29 |
} |
| 30 |
|
| 31 |
__host__ void use_ctad_host() { |
| 32 |
CTADType ctad_from_two_args(1, 1); |
| 33 |
CTADType ctad_from_one_arg(1); |
| 34 |
CTADType ctad_from_three_args(1, 2, 3); |
| 35 |
} |
| 36 |
|
| 37 |
__device__ void use_ctad_device() { |
| 38 |
CTADType ctad_from_two_args(1, 1); |
| 39 |
CTADType ctad_from_one_arg(1); |
| 40 |
CTADType<int> ctad_from_three_args(1, 2, 3); // expected-error {{no matching constructor for initialization of 'CTADType<int>'}} |
| 41 |
} |
| 42 |
|
| 43 |
__global__ void use_ctad_global() { |
| 44 |
CTADType ctad_from_two_args(1, 1); |
| 45 |
CTADType ctad_from_one_arg(1); |
| 46 |
CTADType<int> ctad_from_three_args(1, 2, 3); // expected-error {{no matching constructor for initialization of 'CTADType<int>'}} |
| 47 |
} |