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