| 1 |
// P0634R3 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
// OK, return type of a function declaration at global scope. |
| 5 |
template<class T> T::R f(); |
| 6 |
|
| 7 |
// Ill-formed (no diagnostic required), attempt to declare |
| 8 |
// a void variable template |
| 9 |
template<class T> void f(T::R); // { dg-error "declared void" } |
| 10 |
|
| 11 |
template <class T> struct A; |
| 12 |
template <class T> using B = A<T>::U; |
| 13 |
|
| 14 |
template<typename T> |
| 15 |
struct PtrTraits { typedef int Ptr; }; |
| 16 |
|
| 17 |
template<class T> struct S { |
| 18 |
// OK, in a defining-type-id. |
| 19 |
using Ptr = PtrTraits<T>::Ptr; |
| 20 |
|
| 21 |
// OK, trailing-return-type. |
| 22 |
auto g() -> S<T*>::Ptr; |
| 23 |
|
| 24 |
// OK, class scope |
| 25 |
T::R |
| 26 |
f (T::P p) |
| 27 |
{ |
| 28 |
// OK, type-id of a static_cast |
| 29 |
return static_cast<T::R>(p); |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
template<typename T> |
| 34 |
void f () |
| 35 |
{ |
| 36 |
// Variable pf of type void* initialized with T::X |
| 37 |
void (*pf)(T::X); |
| 38 |
|
| 39 |
// Error: T::X at block scope does not denote a type |
| 40 |
// (attempt to declare a void variable) |
| 41 |
void g(T::X); // { dg-error "declared void" } |
| 42 |
} |