freebsd-dev/test/Parser/cxx-friend.cpp

33 lines
626 B
C++
Raw Normal View History

2009-10-14 18:03:49 +00:00
// RUN: clang-cc -fsyntax-only -verify %s
2009-06-02 17:58:47 +00:00
class C {
friend class D;
};
class A {
public:
2009-10-14 18:03:49 +00:00
void f();
};
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-06-02 17:58:47 +00:00
};
class B {
// 'A' here should refer to the declaration above.
friend class A;
2009-10-14 18:03:49 +00:00
friend C; // expected-error {{must specify 'class' to befriend}}
friend U; // expected-error {{must specify 'union' to befriend}}
friend int; // expected-error {{friends can only be classes or functions}}
friend void myfunc();
void f(A *a) { a->f(); }
2009-06-02 17:58:47 +00:00
};
2009-10-14 18:03:49 +00:00