1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s
3 template <typename
> struct TS
; // #template
7 friend int, long, char;
9 // We simply diagnose and ignore the '...' here.
10 friend float...; // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
12 friend short..., unsigned, unsigned short...; // expected-error 2 {{pack expansion does not contain any unexpanded parameter packs}}
15 friend struct TS
, int; // expected-error {{a friend declaration that befriends a template must contain exactly one type-specifier}}
17 double friend; // expected-error {{'friend' must appear first in a non-function declaration}}
18 double friend, double; // expected-error {{expected member name or ';' after declaration specifiers}}
22 struct C
{ template<class T
> class Nested
; };
24 template <typename
, typename
>
25 struct D
{ template<class T
> class Nested
; };
28 struct E
{ template<class T
> class Nested
; };
30 template<class... Ts
> // expected-note {{template parameter is declared here}}
34 friend class Ts
...; // expected-error {{declaration of 'Ts' shadows template parameter}}
35 // expected-error@-1 {{pack expansion does not contain any unexpanded parameter packs}}
37 // TODO: Fix-it hint to insert '...'.
38 friend Ts
; // expected-error {{friend declaration contains unexpanded parameter pack}}
41 friend Us
...; // expected-error {{friend type templates must use an elaborated type}}
43 template<class... Us
> // expected-note {{is declared here}}
44 friend class Us
...; // expected-error {{declaration of 'Us' shadows template parameter}}
47 friend class C
<Ts
>::template Nested
<U
>...; // expected-error {{cannot specialize a dependent template}}
50 friend class C
<Ts
...>::template Nested
<Us
>...; // expected-error {{cannot specialize a dependent template}}
52 // Nonsense (see CWG 2917).
54 friend class C
<Us
>::Nested
...; // expected-error {{friend declaration expands pack 'Us' that is declared it its own template parameter list}}
57 friend class E
<Bs
>::Nested
...; // expected-error {{friend declaration expands pack 'Bs' that is declared it its own template parameter list}}
59 // FIXME: Both of these should be valid, but we can't handle these at
60 // the moment because the NNS is dependent.
62 friend class TS
<Ts
>::Nested
...; // expected-warning {{dependent nested name specifier 'TS<Ts>::' for friend template declaration is not supported; ignoring this friend declaration}}
65 friend class D
<T
, Ts
>::Nested
...; // expected-warning {{dependent nested name specifier 'D<T, Ts>::' for friend class declaration is not supported; turning off access control for 'VS'}}
68 namespace length_mismatch
{
70 template <typename
...>
75 template <typename
...Ts
>
77 template <typename
...Us
>
79 // expected-error@+2 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (1 vs. 2)}}
80 // expected-error@+1 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (2 vs. 1)}}
81 friend class Ts::template Nested
<Us
>::Foo
...;
87 S
<A
, A
>::T
<int, long> s2
;
88 S
<A
>::T
<int, long> s3
; // expected-note {{in instantiation of}}
89 S
<A
, A
>::T
<int> s4
; // expected-note {{in instantiation of}}