explicit-specialization-member.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. template<typename T>
  3. struct X0 {
  4. typedef T* type;
  5. void f0(T);
  6. void f1(type);
  7. };
  8. template<> void X0<char>::f0(char);
  9. template<> void X0<char>::f1(type);
  10. namespace PR6161 {
  11. template<typename _CharT>
  12. class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \
  13. // expected-error{{expected class name}}
  14. {
  15. static locale::id id; // expected-error{{use of undeclared identifier}}
  16. };
  17. numpunct<char>::~numpunct();
  18. }
  19. namespace PR12331 {
  20. template<typename T> struct S {
  21. struct U { static const int n = 5; };
  22. enum E { e = U::n }; // expected-note {{implicit instantiation first required here}}
  23. int arr[e];
  24. };
  25. template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}}
  26. }
  27. namespace PR18246 {
  28. template<typename T>
  29. class Baz {
  30. public:
  31. template<int N> void bar();
  32. };
  33. template<typename T>
  34. template<int N>
  35. void Baz<T>::bar() { // expected-note {{couldn't infer template argument 'N'}}
  36. }
  37. // FIXME: We shouldn't try to match this against a prior declaration if
  38. // template parameter matching failed.
  39. template<typename T>
  40. void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} \
  41. // expected-error {{no function template matches}}
  42. }
  43. }
  44. namespace PR19340 {
  45. template<typename T> struct Helper {
  46. template<int N> static void func(const T *m) {} // expected-note {{failed template argument deduction}}
  47. };
  48. template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} \
  49. // expected-error {{no function template matches}}
  50. }