class-template-ctor-initializer.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template<class X> struct A {};
  3. template<class X> struct B : A<X> {
  4. B() : A<X>() {}
  5. };
  6. B<int> x;
  7. template<class X> struct B1 : A<X> {
  8. typedef A<X> Base;
  9. B1() : Base() {}
  10. };
  11. B1<int> x1;
  12. template<typename T> struct Tmpl { };
  13. template<typename T> struct TmplB { };
  14. struct TmplC : Tmpl<int> {
  15. TmplC() :
  16. Tmpl<int>(),
  17. TmplB<int>() { } // expected-error {{type 'TmplB<int>' is not a direct or virtual base of 'TmplC'}}
  18. };
  19. struct TmplD : Tmpl<char>, TmplB<char> {
  20. TmplD():
  21. Tmpl<int>(), // expected-error {{type 'Tmpl<int>' is not a direct or virtual base of 'TmplD'}}
  22. TmplB<char>() {}
  23. };
  24. namespace PR7259 {
  25. class Base {
  26. public:
  27. Base() {}
  28. };
  29. template <class ParentClass>
  30. class Derived : public ParentClass {
  31. public:
  32. Derived() : Base() {}
  33. };
  34. class Final : public Derived<Base> {
  35. };
  36. int
  37. main (void)
  38. {
  39. Final final;
  40. return 0;
  41. }
  42. }
  43. namespace NonDependentError {
  44. struct Base { Base(int); }; // expected-note 2{{candidate}}
  45. template<typename T>
  46. struct Derived1 : Base {
  47. Derived1() : Base(1, 2) {} // expected-error {{no matching constructor}}
  48. };
  49. template<typename T>
  50. struct Derived2 : Base {
  51. Derived2() : BaseClass(1) {} // expected-error {{does not name a non-static data member or base}}
  52. };
  53. Derived1<void> d1;
  54. Derived2<void> d2;
  55. }