integer-literal-printing.cpp 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
  2. // PR11179
  3. template <short T> class Type1 {};
  4. template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: expects an l-value for 1st argument}}
  5. template <unsigned short T> class Type2 {};
  6. template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: expects an l-value for 1st argument}}
  7. enum class boolTy : bool {
  8. b = 0,
  9. };
  10. template <boolTy T> struct Type3Helper;
  11. template <> struct Type3Helper<boolTy::b> { typedef boolTy Ty; };
  12. template <boolTy T, typename Type3Helper<T>::Ty U> struct Type3 {};
  13. // PR14386
  14. enum class charTy : char {
  15. c = 0,
  16. };
  17. template <charTy T> struct Type4Helper;
  18. template <> struct Type4Helper<charTy::c> { typedef charTy Ty; };
  19. template <charTy T, typename Type4Helper<T>::Ty U> struct Type4 {};
  20. enum class scharTy : signed char {
  21. c = 0,
  22. };
  23. template <scharTy T> struct Type5Helper;
  24. template <> struct Type5Helper<scharTy::c> { typedef scharTy Ty; };
  25. template <scharTy T, typename Type5Helper<T>::Ty U> struct Type5 {};
  26. enum class ucharTy : unsigned char {
  27. c = 0,
  28. };
  29. template <ucharTy T> struct Type6Helper;
  30. template <> struct Type6Helper<ucharTy::c> { typedef ucharTy Ty; };
  31. template <ucharTy T, typename Type6Helper<T>::Ty U> struct Type6 {};
  32. enum class wcharTy : wchar_t {
  33. c = 0,
  34. };
  35. template <wcharTy T> struct Type7Helper;
  36. template <> struct Type7Helper<wcharTy::c> { typedef wcharTy Ty; };
  37. template <wcharTy T, typename Type7Helper<T>::Ty U> struct Type7 {};
  38. enum class char16Ty : char16_t {
  39. c = 0,
  40. };
  41. template <char16Ty T> struct Type8Helper;
  42. template <> struct Type8Helper<char16Ty::c> { typedef char16Ty Ty; };
  43. template <char16Ty T, typename Type8Helper<T>::Ty U> struct Type8 {};
  44. enum class char32Ty : char16_t {
  45. c = 0,
  46. };
  47. template <char32Ty T> struct Type9Helper;
  48. template <> struct Type9Helper<char32Ty::c> { typedef char32Ty Ty; };
  49. template <char32Ty T, typename Type9Helper<T>::Ty U> struct Type9 {};
  50. void Function() {
  51. Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}}
  52. Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}}
  53. struct Type3<boolTy::b, "3"> t3; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type3Helper<(boolTy)false>::Ty' (aka 'boolTy')}}
  54. struct Type4<charTy::c, "4"> t4; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type4Helper<(charTy)'\x00'>::Ty' (aka 'charTy')}}
  55. struct Type5<scharTy::c, "5"> t5; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type5Helper<(scharTy)'\x00'>::Ty' (aka 'scharTy')}}
  56. struct Type6<ucharTy::c, "6"> t6; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type6Helper<(ucharTy)'\x00'>::Ty' (aka 'ucharTy')}}
  57. struct Type7<wcharTy::c, "7"> t7; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type7Helper<(wcharTy)L'\x00'>::Ty' (aka 'wcharTy')}}
  58. struct Type8<char16Ty::c, "8"> t8; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type8Helper<(char16Ty)u'\x00'>::Ty' (aka 'char16Ty')}}
  59. struct Type9<char32Ty::c, "9"> t9; // expected-error{{value of type 'const char [2]' is not implicitly convertible to 'typename Type9Helper<(char32Ty)u'\x00'>::Ty' (aka 'char32Ty')}}
  60. }