Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | 0d8df78 | 2009-08-29 19:37:28 +0000 | [diff] [blame] | 2 | |
John McCall | fda8e12 | 2009-12-03 00:58:24 +0000 | [diff] [blame] | 3 | namespace test0 { |
| 4 | namespace N { } |
Douglas Gregor | 48c32a7 | 2009-11-17 06:07:40 +0000 | [diff] [blame] | 5 | |
John McCall | fda8e12 | 2009-12-03 00:58:24 +0000 | [diff] [blame] | 6 | template<typename T> |
| 7 | struct A { |
| 8 | void f(); |
| 9 | }; |
Anders Carlsson | 0d8df78 | 2009-08-29 19:37:28 +0000 | [diff] [blame] | 10 | |
John McCall | fda8e12 | 2009-12-03 00:58:24 +0000 | [diff] [blame] | 11 | template<typename T> |
| 12 | struct B : A<T> { |
| 13 | using A<T>::f; |
| 14 | |
| 15 | void g() { |
| 16 | using namespace N; |
| 17 | f(); |
| 18 | } |
| 19 | }; |
| 20 | |
| 21 | template struct B<int>; |
| 22 | } |
| 23 | |
| 24 | namespace test1 { |
| 25 | template <class Derived> struct Visitor1 { |
| 26 | void Visit(struct Object1*); |
| 27 | }; |
| 28 | template <class Derived> struct Visitor2 { |
| 29 | void Visit(struct Object2*); // expected-note {{candidate function}} |
| 30 | }; |
| 31 | |
| 32 | template <class Derived> struct JoinVisitor |
| 33 | : Visitor1<Derived>, Visitor2<Derived> { |
| 34 | typedef Visitor1<Derived> Base1; |
| 35 | typedef Visitor2<Derived> Base2; |
| 36 | |
| 37 | void Visit(struct Object1*); // expected-note {{candidate function}} |
| 38 | using Base2::Visit; |
| 39 | }; |
| 40 | |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 41 | class Knot : public JoinVisitor<Knot> { |
John McCall | fda8e12 | 2009-12-03 00:58:24 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | void test() { |
| 45 | Knot().Visit((struct Object1*) 0); |
| 46 | Knot().Visit((struct Object2*) 0); |
| 47 | Knot().Visit((struct Object3*) 0); // expected-error {{no matching member function for call}} |
Anders Carlsson | 0d8df78 | 2009-08-29 19:37:28 +0000 | [diff] [blame] | 48 | } |
John McCall | fda8e12 | 2009-12-03 00:58:24 +0000 | [diff] [blame] | 49 | } |
John McCall | 323c310 | 2009-12-22 22:26:37 +0000 | [diff] [blame] | 50 | |
| 51 | // PR5847 |
| 52 | namespace test2 { |
| 53 | namespace ns { |
| 54 | void foo(); |
| 55 | } |
| 56 | |
| 57 | template <class T> void bar(T* ptr) { |
| 58 | using ns::foo; |
| 59 | foo(); |
| 60 | } |
| 61 | |
| 62 | template void bar(char *); |
| 63 | } |
Douglas Gregor | 1b39820 | 2010-09-29 17:58:28 +0000 | [diff] [blame] | 64 | |
| 65 | namespace test3 { |
| 66 | template <typename T> struct t { |
| 67 | struct s1 { |
| 68 | T f1() const; |
| 69 | }; |
| 70 | struct s2 : s1 { |
| 71 | using s1::f1; |
| 72 | T f1() const; |
| 73 | }; |
| 74 | }; |
| 75 | |
| 76 | void f2() |
| 77 | { |
| 78 | t<int>::s2 a; |
| 79 | t<int>::s2 const & b = a; |
| 80 | b.f1(); |
| 81 | } |
| 82 | } |