| 1 |
// RUN: %clang_cc1 -std=c++17 -triple nvptx64-nvidia-cuda -fsyntax-only \ |
| 2 |
// RUN: -fcuda-is-device -verify %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 <typename T> |
| 9 |
struct S { |
| 10 |
__host__ __device__ S(T); |
| 11 |
}; |
| 12 |
|
| 13 |
// A host+device deduction guide is allowed and participates in CTAD, but its |
| 14 |
// explicit target attributes are deprecated and will be rejected in a future |
| 15 |
// Clang version. |
| 16 |
template <typename T> |
| 17 |
__host__ __device__ S(T) -> S<T>; // expected-warning {{use of CUDA/HIP target attributes on deduction guides is deprecated; they will be rejected in a future version of Clang}} |
| 18 |
|
| 19 |
__host__ __device__ void use_hd_guide() { |
| 20 |
S s(42); // uses the explicit __host__ __device__ deduction guide above |
| 21 |
} |
| 22 |
|
| 23 |
// CUDA/HIP target attributes on deduction guides are rejected when they make |
| 24 |
// the guide host-only, device-only, or a kernel. |
| 25 |
template <typename U> |
| 26 |
__host__ S(U) -> S<U>; // expected-error {{in CUDA/HIP, deduction guides may only be annotated with '__host__ __device__'; '__host__'-only, '__device__'-only, or '__global__' deduction guides are not allowed}} |
| 27 |
|
| 28 |
template <typename V> |
| 29 |
__device__ S(V) -> S<V>; // expected-error {{in CUDA/HIP, deduction guides may only be annotated with '__host__ __device__'; '__host__'-only, '__device__'-only, or '__global__' deduction guides are not allowed}} |
| 30 |
|
| 31 |
template <typename W> |
| 32 |
__global__ S(W) -> S<W>; // expected-error {{in CUDA/HIP, deduction guides may only be annotated with '__host__ __device__'; '__host__'-only, '__device__'-only, or '__global__' deduction guides are not allowed}} |