2009-12-15 23:14:24 +03:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-05-12 02:55:49 +04:00
|
|
|
|
|
|
|
friend class A; // expected-error {{'friend' used outside of class}}
|
|
|
|
void f() { friend class A; } // expected-error {{'friend' used outside of class}}
|
|
|
|
class C { friend class A; };
|
|
|
|
class D { void f() { friend class A; } }; // expected-error {{'friend' used outside of class}}
|
2009-12-11 23:04:54 +03:00
|
|
|
|
|
|
|
// PR5760
|
|
|
|
namespace test0 {
|
|
|
|
namespace ns {
|
|
|
|
void f(int);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
friend void ns::f(int a);
|
|
|
|
};
|
|
|
|
}
|
2009-12-18 02:21:11 +03:00
|
|
|
|
|
|
|
// Test derived from LLVM's Registry.h
|
|
|
|
namespace test1 {
|
|
|
|
template <class T> struct Outer {
|
|
|
|
void foo(T);
|
|
|
|
struct Inner {
|
|
|
|
friend void Outer::foo(T);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
(void) Outer<int>::Inner();
|
|
|
|
}
|
|
|
|
}
|
2009-12-23 03:44:38 +03:00
|
|
|
|
|
|
|
// PR5476
|
|
|
|
namespace test2 {
|
|
|
|
namespace foo {
|
|
|
|
void Func(int x);
|
|
|
|
}
|
|
|
|
|
|
|
|
class Bar {
|
|
|
|
friend void ::test2::foo::Func(int x);
|
|
|
|
};
|
|
|
|
}
|
2009-12-23 04:09:14 +03:00
|
|
|
|
|
|
|
// PR5134
|
|
|
|
namespace test3 {
|
|
|
|
class Foo {
|
2010-07-14 10:36:18 +04:00
|
|
|
friend const int getInt(int inInt = 0);
|
2010-07-13 12:18:22 +04:00
|
|
|
|
2009-12-23 04:09:14 +03:00
|
|
|
};
|
|
|
|
}
|
2010-06-09 01:27:36 +04:00
|
|
|
|
|
|
|
namespace test4 {
|
|
|
|
class T4A {
|
|
|
|
friend class T4B;
|
|
|
|
|
|
|
|
public:
|
|
|
|
T4A(class T4B *);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
T4B *mB; // error here
|
|
|
|
};
|
|
|
|
|
|
|
|
class T4B {};
|
|
|
|
}
|
2010-10-09 08:39:54 +04:00
|
|
|
|
|
|
|
namespace rdar8529993 {
|
|
|
|
struct A { ~A(); }; // expected-note {{nearly matches}}
|
|
|
|
|
|
|
|
struct B : A
|
|
|
|
{
|
|
|
|
template<int> friend A::~A(); // expected-error {{does not match}}
|
|
|
|
};
|
|
|
|
}
|
2010-11-10 06:01:53 +03:00
|
|
|
|
|
|
|
// PR7915
|
|
|
|
namespace test5 {
|
|
|
|
struct A;
|
|
|
|
struct A1 { friend void A(); };
|
|
|
|
|
|
|
|
struct B { friend void B(); };
|
|
|
|
}
|
2010-11-29 21:19:25 +03:00
|
|
|
|
|
|
|
// PR8479
|
|
|
|
namespace test6_1 {
|
|
|
|
class A {
|
|
|
|
public:
|
|
|
|
private:
|
|
|
|
friend class vectorA;
|
|
|
|
A() {}
|
|
|
|
};
|
|
|
|
class vectorA {
|
|
|
|
public:
|
|
|
|
vectorA(int i, const A& t = A()) {}
|
|
|
|
};
|
|
|
|
void f() {
|
|
|
|
vectorA v(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
namespace test6_2 {
|
|
|
|
template<class T>
|
|
|
|
class vector {
|
|
|
|
public:
|
|
|
|
vector(int i, const T& t = T()) {}
|
|
|
|
};
|
|
|
|
class A {
|
|
|
|
public:
|
|
|
|
private:
|
|
|
|
friend class vector<A>;
|
|
|
|
A() {}
|
|
|
|
};
|
|
|
|
void f() {
|
|
|
|
vector<A> v(1);
|
|
|
|
}
|
|
|
|
}
|