150
|
1 // RUN: %clang_cc1 %s -fsyntax-only -verify
|
|
2 // RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-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
|
221
|
9 #elif defined(__aarch64__)
|
|
10 // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD non-NetBSD.
|
|
11 #if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
|
|
12 #define WCHAR_T_TYPE int
|
|
13 #else
|
|
14 #define WCHAR_T_TYPE unsigned int
|
|
15 #endif
|
|
16 #elif defined(__arm) || defined(__MVS__)
|
150
|
17 #define WCHAR_T_TYPE unsigned int
|
|
18 #elif defined(__sun)
|
|
19 #if defined(__LP64__)
|
|
20 #define WCHAR_T_TYPE int
|
|
21 #else
|
|
22 #define WCHAR_T_TYPE long
|
|
23 #endif
|
221
|
24 #else /* Solaris, Linux, non-arm64 macOS, ... */
|
150
|
25 #define WCHAR_T_TYPE int
|
|
26 #endif
|
|
27
|
|
28 int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
|
|
29
|
|
30 void foo() {
|
|
31 WCHAR_T_TYPE t1[] = L"x";
|
|
32 wchar_t tab[] = L"x";
|
|
33 WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializing wide char array with non-wide string literal}}
|
|
34 char t3[] = L"x"; // expected-error {{initializing char array with wide string literal}}
|
|
35 }
|