1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 class C {
4 friend class D;
5 };
6
7 class A {
8 public:
9 void f();
10 };
11
12 friend int x; // expected-error {{'friend' used outside of class}}
13
14 friend class D {}; // expected-error {{'friend' used outside of class}}
15
16 union U {
17 int u1;
18 };
19
20 class B {
21 // 'A' here should refer to the declaration above.
22 friend class A;
23
24 friend C; // expected-warning {{specify 'class' to befriend}}
25 friend U; // expected-warning {{specify 'union' to befriend}}
26 friend int; // expected-warning {{non-class friend type 'int'}}
27
28 friend void myfunc();
29
f(A * a)30 void f(A *a) { a->f(); }
31 };
32
bar()33 inline void bar() {} // expected-note {{previous definition is here}}
34 class E {
bar()35 friend void bar() {} // expected-error {{redefinition of 'bar'}}
36 };
37
38
39
40
41 template <typename t1, typename t2> class some_template;
42 friend // expected-error {{'friend' used outside of class}}
43 some_template<foo, bar>& // expected-error {{use of undeclared identifier 'foo'}}
44 ; // expected-error {{expected unqualified-id}}
45