2009-08-06 10:15:43 +08:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s
|
2009-05-06 12:46:28 +08:00
|
|
|
|
|
|
|
class C {
|
|
|
|
friend class D;
|
|
|
|
};
|
2009-05-12 06:25:03 +08:00
|
|
|
|
|
|
|
class A {
|
|
|
|
public:
|
|
|
|
void f();
|
|
|
|
};
|
|
|
|
|
2009-08-06 10:15:43 +08:00
|
|
|
friend int x; // expected-error {{'friend' used outside of class}}
|
|
|
|
|
|
|
|
friend class D {}; // expected-error {{'friend' used outside of class}}
|
|
|
|
|
|
|
|
union U {
|
|
|
|
int u1;
|
|
|
|
};
|
|
|
|
|
2009-05-12 06:25:03 +08:00
|
|
|
class B {
|
|
|
|
// 'A' here should refer to the declaration above.
|
|
|
|
friend class A;
|
|
|
|
|
2009-08-06 10:15:43 +08:00
|
|
|
friend C; // expected-error {{must specify 'class' in a friend class declaration}}
|
|
|
|
friend U; // expected-error {{must specify 'union' in a friend union declaration}}
|
|
|
|
friend int; // expected-error {{friends can only be classes or functions}}
|
|
|
|
|
|
|
|
friend void myfunc();
|
|
|
|
|
|
|
|
void f(A *a) { a->f(); }
|
2009-05-12 06:25:03 +08:00
|
|
|
};
|
2009-08-06 10:15:43 +08:00
|
|
|
|