wchar.c 841 B

123456789101112131415161718192021222324
  1. // RUN: %clang_cc1 %s -fsyntax-only -verify
  2. // RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR
  3. typedef __WCHAR_TYPE__ wchar_t;
  4. #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
  5. || defined(_M_X64) || defined(__PS4__) || defined(SHORT_WCHAR)
  6. #define WCHAR_T_TYPE unsigned short
  7. #elif defined(__arm) || defined(__aarch64__)
  8. #define WCHAR_T_TYPE unsigned int
  9. #elif defined(__sun)
  10. #define WCHAR_T_TYPE long
  11. #else /* Solaris. */
  12. #define WCHAR_T_TYPE int
  13. #endif
  14. int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
  15. void foo() {
  16. WCHAR_T_TYPE t1[] = L"x";
  17. wchar_t tab[] = L"x";
  18. WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializing wide char array with non-wide string literal}}
  19. char t3[] = L"x"; // expected-error {{initializing char array with wide string literal}}
  20. }