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

41 lines
890 B
C++
Raw Normal View History

2010-01-01 10:34:51 +00:00
// RUN: %clang_cc1 -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;
2010-05-04 16:12:48 +00:00
friend C; // expected-warning {{must specify 'class' to befriend}}
friend U; // expected-warning {{must specify 'union' to befriend}}
friend int; // expected-warning {{non-class type 'int' cannot be a friend}}
2009-10-14 18:03:49 +00:00
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
2009-12-15 18:49:47 +00:00
template <typename t1, typename t2> class some_template;
friend // expected-error {{'friend' used outside of class}}
some_template<foo, bar>& // expected-error {{use of undeclared identifier 'foo'}}
; // expected-error {{expected unqualified-id}}