61 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s2 3struct 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 11template<typename T>12struct 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 20void 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}}25template<typename T = int, typename U>26struct ClassTempl{};27 28struct 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 39template<typename Ty>40struct 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 48void Inst2() {49 HasFriendClassTempl2<int>(); // #INST250}51 52// expected-error@+2{{template parameter missing a default argument}}53// expected-note@+1{{previous default template argument defined here}}54template<typename T = int, typename U>55static constexpr U VarTempl;56 57// expected-error@+2{{template parameter missing a default argument}}58// expected-note@+1{{previous default template argument defined here}}59template<typename T = int, typename U>60using TypeAlias = U;61