| 1 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
struct S { |
| 4 |
template<typename Ty = int> |
| 5 |
friend void foo(auto){} |
| 6 |
|
| 7 |
template<typename Ty = int, typename Tz> |
| 8 |
friend void foo2(){} |
| 9 |
}; |
| 10 |
|
| 11 |
template<typename T> |
| 12 |
struct TemplS { |
| 13 |
template<typename Ty = int> |
| 14 |
friend void foo3(auto){} |
| 15 |
|
| 16 |
template<typename Ty = int, typename Tz> |
| 17 |
friend void foo4(){} |
| 18 |
}; |
| 19 |
|
| 20 |
void Inst() { |
| 21 |
TemplS<int>(); |
| 22 |
} |
| 23 |
// expected-error@+2{{template parameter missing a default argument}} |
| 24 |
// expected-note@+1{{previous default template argument defined here}} |
| 25 |
template<typename T = int, typename U> |
| 26 |
struct ClassTempl{}; |
| 27 |
|
| 28 |
struct HasFriendClassTempl { |
| 29 |
// expected-error@+1{{default template argument not permitted on a friend template}} |
| 30 |
template<typename T = int, typename U> |
| 31 |
friend struct Friend; |
| 32 |
|
| 33 |
// expected-error@+3{{cannot define a type in a friend declaration}} |
| 34 |
// expected-error@+1{{default template argument not permitted on a friend template}} |
| 35 |
template<typename T = int, typename U> |
| 36 |
friend struct Friend2{}; |
| 37 |
}; |
| 38 |
|
| 39 |
template<typename Ty> |
| 40 |
struct HasFriendClassTempl2 { |
| 41 |
// expected-error@+3{{template parameter missing a default argument}} |
| 42 |
// expected-note@+2{{previous default template argument defined here}} |
| 43 |
// expected-note@#INST2{{in instantiation of template class}} |
| 44 |
template<typename T = int, typename U> |
| 45 |
friend struct Friend; |
| 46 |
}; |
| 47 |
|
| 48 |
void Inst2() { |
| 49 |
HasFriendClassTempl2<int>(); // #INST2 |
| 50 |
} |
| 51 |
|
| 52 |
// expected-error@+2{{template parameter missing a default argument}} |
| 53 |
// expected-note@+1{{previous default template argument defined here}} |
| 54 |
template<typename T = int, typename U> |
| 55 |
static constexpr U VarTempl; |
| 56 |
|
| 57 |
// expected-error@+2{{template parameter missing a default argument}} |
| 58 |
// expected-note@+1{{previous default template argument defined here}} |
| 59 |
template<typename T = int, typename U> |
| 60 |
using TypeAlias = U; |