diff options
Diffstat (limited to 'test/Parser/cxx-friend.cpp')
-rw-r--r-- | test/Parser/cxx-friend.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp index ea30ddcbd0a8..14b31af761d3 100644 --- a/test/Parser/cxx-friend.cpp +++ b/test/Parser/cxx-friend.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only %s +// RUN: clang-cc -fsyntax-only -verify %s class C { friend class D; @@ -6,12 +6,27 @@ class C { class A { public: - void f(); + 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; }; class B { // 'A' here should refer to the declaration above. friend class A; - void f(A *a) { a->f(); } + 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(); } }; + |