blob: 59350b5663676540ad76887cd5459c54e56401c5 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlssonf47f7a12009-05-06 04:46:28 +00002
3class C {
4 friend class D;
5};
Anders Carlsson5dc2af12009-05-11 22:25:03 +00006
7class A {
8public:
Mike Stump1eb44332009-09-09 15:08:12 +00009 void f();
Anders Carlsson5dc2af12009-05-11 22:25:03 +000010};
11
John McCall67d1a672009-08-06 02:15:43 +000012friend int x; // expected-error {{'friend' used outside of class}}
13
14friend class D {}; // expected-error {{'friend' used outside of class}}
15
16union U {
17 int u1;
18};
19
Anders Carlsson5dc2af12009-05-11 22:25:03 +000020class B {
21 // 'A' here should refer to the declaration above.
22 friend class A;
23
Douglas Gregor06245bf2010-04-07 17:57:12 +000024 friend C; // expected-warning {{must specify 'class' to befriend}}
25 friend U; // expected-warning {{must specify 'union' to befriend}}
26 friend int; // expected-warning {{non-class type 'int' cannot be a friend}}
John McCall67d1a672009-08-06 02:15:43 +000027
28 friend void myfunc();
29
30 void f(A *a) { a->f(); }
Anders Carlsson5dc2af12009-05-11 22:25:03 +000031};
John McCall67d1a672009-08-06 02:15:43 +000032
Chris Lattnerbd87c0b2009-12-07 00:48:47 +000033
34
35
36
37template <typename t1, typename t2> class some_template;
38friend // expected-error {{'friend' used outside of class}}
39some_template<foo, bar>& // expected-error {{use of undeclared identifier 'foo'}}
40 ; // expected-error {{expected unqualified-id}}