instantiate-using-decl.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace test0 {
  3. namespace N { }
  4. template<typename T>
  5. struct A {
  6. void f();
  7. };
  8. template<typename T>
  9. struct B : A<T> {
  10. using A<T>::f;
  11. void g() {
  12. using namespace N;
  13. f();
  14. }
  15. };
  16. template struct B<int>;
  17. }
  18. namespace test1 {
  19. template <class Derived> struct Visitor1 {
  20. void Visit(struct Object1*);
  21. };
  22. template <class Derived> struct Visitor2 {
  23. void Visit(struct Object2*); // expected-note {{candidate function}}
  24. };
  25. template <class Derived> struct JoinVisitor
  26. : Visitor1<Derived>, Visitor2<Derived> {
  27. typedef Visitor1<Derived> Base1;
  28. typedef Visitor2<Derived> Base2;
  29. void Visit(struct Object1*); // expected-note {{candidate function}}
  30. using Base2::Visit;
  31. };
  32. class Knot : public JoinVisitor<Knot> {
  33. };
  34. void test() {
  35. Knot().Visit((struct Object1*) 0);
  36. Knot().Visit((struct Object2*) 0);
  37. Knot().Visit((struct Object3*) 0); // expected-error {{no matching member function for call}}
  38. }
  39. }
  40. // PR5847
  41. namespace test2 {
  42. namespace ns {
  43. void foo();
  44. }
  45. template <class T> void bar(T* ptr) {
  46. using ns::foo;
  47. foo();
  48. }
  49. template void bar(char *);
  50. }
  51. namespace test3 {
  52. template <typename T> struct t {
  53. struct s1 {
  54. T f1() const;
  55. };
  56. struct s2 : s1 {
  57. using s1::f1;
  58. T f1() const;
  59. };
  60. };
  61. void f2()
  62. {
  63. t<int>::s2 a;
  64. t<int>::s2 const & b = a;
  65. b.f1();
  66. }
  67. }
  68. namespace PR16936 {
  69. // Make sure both using decls are properly considered for
  70. // overload resolution.
  71. template<class> struct A {
  72. void access(int);
  73. };
  74. template<class> struct B {
  75. void access();
  76. };
  77. template<class CELL> struct X : public A<CELL>, public B<CELL> {
  78. using A<CELL>::access;
  79. using B<CELL>::access;
  80. void f() {
  81. access(0);
  82. }
  83. };
  84. void f() {
  85. X<int> x;
  86. x.f();
  87. }
  88. }