ms-class-specialization-class-scope.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s -Wno-microsoft
  2. // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s -Wno-microsoft
  3. class A {
  4. public:
  5. template<typename T> struct X { typedef int x; };
  6. X<int>::x a; // expected-note {{implicit instantiation first required here}}
  7. template<> struct X<int>; // expected-error {{explicit specialization of 'A::X<int>' after instantiation}}
  8. template<> struct X<char>; // expected-note {{forward declaration}}
  9. X<char>::x b; // expected-error {{incomplete type 'A::X<char>' named in nested name specifier}}
  10. template<> struct X<double> {
  11. typedef int y;
  12. };
  13. X<double>::y c;
  14. template<> struct X<float> {}; // expected-note {{previous definition is here}}
  15. template<> struct X<float> {}; // expected-error {{redefinition of 'A::X<float>'}}
  16. };
  17. A::X<void>::x axv;
  18. A::X<float>::x axf; // expected-error {{no type named 'x'}}
  19. template<class T> class B {
  20. public:
  21. template<typename U> struct X { typedef int x; };
  22. typename X<int>::x a; // expected-note {{implicit instantiation first required here}}
  23. template<> struct X<int>; // expected-error {{explicit specialization of 'X<int>' after instantiation}}
  24. template<> struct X<char>; // expected-note {{forward declaration}}
  25. typename X<char>::x b; // expected-error {{incomplete type 'B<float>::X<char>' named in nested name specifier}}
  26. template<> struct X<double> {
  27. typedef int y;
  28. };
  29. typename X<double>::y c;
  30. template<> struct X<float> {}; // expected-note {{previous definition is here}}
  31. template<> struct X<T> {}; // expected-error {{redefinition of 'X<float>'}}
  32. };
  33. B<float> b; // expected-note {{in instantiation of}}