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