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
33
34
35
36
37template <typename t1, typename t2> class some_template;
38friend   // expected-error {{'friend' used outside of class}}
39some_template<foo, bar>&  // expected-error {{use of undeclared identifier 'foo'}}
40  ;  // expected-error {{expected unqualified-id}}
41