char-literal.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s
  3. #ifndef __cplusplus
  4. typedef __WCHAR_TYPE__ wchar_t;
  5. typedef __CHAR16_TYPE__ char16_t;
  6. typedef __CHAR32_TYPE__ char32_t;
  7. #endif
  8. int a = 'ab'; // expected-warning {{multi-character character constant}}
  9. int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
  10. int c = 'APPS'; // expected-warning {{multi-character character constant}}
  11. char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
  12. char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
  13. #ifdef __cplusplus
  14. auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
  15. #endif
  16. char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
  17. char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
  18. wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
  19. wchar_t j = L'\U0010FFFD';
  20. char32_t k = U'\U0010FFFD';
  21. char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
  22. char m = '👿'; // expected-error {{character too large for enclosing character literal type}}
  23. char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
  24. char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
  25. char16_t p[2] = u"\U0000FFFF";
  26. char16_t q[2] = u"\U00010000";
  27. #ifdef __cplusplus
  28. // expected-error@-2 {{too long}}
  29. #endif