[flang][cuda] Do not register global constants (#118582)
[llvm-project.git] / clang / test / Parser / cxx2c-variadic-friends.cpp
blobb7da3e61104812954fdc9337f814e85b44b15e19
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s
3 template <typename> struct TS; // #template
5 struct Errors {
6 friend int, int;
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}}
14 template <typename>
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}}
21 template <typename>
22 struct C { template<class T> class Nested; };
24 template <typename, typename>
25 struct D { template<class T> class Nested; };
27 template <bool>
28 struct E { template<class T> class Nested; };
30 template<class... Ts> // expected-note {{template parameter is declared here}}
31 struct VS {
32 friend Ts...;
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}}
40 template<class... Us>
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}}
46 template<class U>
47 friend class C<Ts>::template Nested<U>...; // expected-error {{cannot specialize a dependent template}}
49 template<class... Us>
50 friend class C<Ts...>::template Nested<Us>...; // expected-error {{cannot specialize a dependent template}}
52 // Nonsense (see CWG 2917).
53 template<class... Us>
54 friend class C<Us>::Nested...; // expected-error {{friend declaration expands pack 'Us' that is declared it its own template parameter list}}
56 template<bool... Bs>
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.
61 template<class ...T>
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}}
64 template<class T>
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 {
69 struct A {
70 template <typename...>
71 struct Nested {
72 struct Foo{};
75 template <typename ...Ts>
76 struct S {
77 template <typename ...Us>
78 struct T {
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...;
85 void f() {
86 S<A>::T<int> s;
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}}