Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | 40a90c8 | 2009-09-13 23:59:13 +0000 | [diff] [blame] | 2 | template<typename T> struct A { |
| 3 | struct B { }; |
| 4 | |
| 5 | friend struct B; |
| 6 | }; |
| 7 | |
| 8 | void f() { |
| 9 | A<int>::B b; |
| 10 | } |
Douglas Gregor | 2208a29 | 2009-09-26 20:57:03 +0000 | [diff] [blame] | 11 | |
| 12 | struct C0 { |
| 13 | friend struct A<int>; |
| 14 | }; |
Douglas Gregor | ce40e2e | 2010-04-12 16:00:01 +0000 | [diff] [blame] | 15 | |
| 16 | namespace PR6770 { |
| 17 | namespace N { |
| 18 | int f1(int); |
| 19 | } |
| 20 | using namespace N; |
| 21 | |
| 22 | namespace M { |
| 23 | float f1(float); |
| 24 | } |
| 25 | using M::f1; |
| 26 | |
| 27 | template<typename T> void f1(T, T); |
| 28 | template <class T> |
| 29 | void f() { |
| 30 | friend class f; // expected-error{{'friend' used outside of class}} |
Richard Trieu | 553b2b2 | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 31 | friend class f1; // expected-error{{'friend' used outside of class}} |
Douglas Gregor | ce40e2e | 2010-04-12 16:00:01 +0000 | [diff] [blame] | 32 | } |
| 33 | } |
Reid Kleckner | 9386417 | 2015-04-08 00:04:47 +0000 | [diff] [blame] | 34 | |
| 35 | namespace friend_redecl_inline { |
| 36 | // We had a bug where instantiating the foo friend declaration would check the |
| 37 | // defined-ness of the most recent decl while checking if the canonical decl was |
| 38 | // inlined. |
| 39 | void foo(); |
| 40 | void bar(); |
| 41 | template <typename T> |
| 42 | class C { |
| 43 | friend void foo(); |
| 44 | friend inline void bar(); |
| 45 | }; |
| 46 | inline void foo() {} |
| 47 | inline void bar() {} |
| 48 | C<int> c; |
| 49 | } |