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 {
|
|
|
|
friend const int getInt(int inInt = 0);
|
|
|
|
};
|
|
|
|
}
|