instantiate-member-initializers.cpp 882 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
  2. template<typename T> struct A {
  3. A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
  4. T a;
  5. };
  6. A<int> a0;
  7. A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
  8. template<typename T> struct B {
  9. B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
  10. a(2) { }
  11. int a;
  12. int b;
  13. };
  14. B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
  15. template <class T> struct AA { AA(int); };
  16. template <class T> class BB : public AA<T> {
  17. public:
  18. BB() : AA<T>(1) {}
  19. };
  20. BB<int> x;
  21. struct X {
  22. X();
  23. };
  24. template<typename T>
  25. struct Y {
  26. Y() : x() {}
  27. X x;
  28. };
  29. Y<int> y;
  30. template<typename T> struct Array {
  31. int a[3];
  32. Array() : a() {}
  33. };
  34. Array<int> s;