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