1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3class C {
4  friend class D;
5};
6
7class A {
8public:
9  void f();
10};
11
12friend int x; // expected-error {{'friend' used outside of class}}
13
14friend class D {}; // expected-error {{'friend' used outside of class}}
15
16union U {
17  int u1;
18};
19
20class 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
30  void f(A *a) { a->f(); }
31};
32
33inline void bar() {} // expected-note {{previous definition is here}}
34class E {
35  friend void bar() {} // expected-error {{redefinition of 'bar'}}
36};
37
38
39
40
41template <typename t1, typename t2> class some_template;
42friend   // expected-error {{'friend' used outside of class}}
43some_template<foo, bar>&  // expected-error {{use of undeclared identifier 'foo'}}
44  ;  // expected-error {{expected unqualified-id}}
45