brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · fa32ae6 Raw
37 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -verify2// RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify -DSHORT_WCHAR3 4typedef __WCHAR_TYPE__ wchar_t;5 6#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \7 || defined(_M_X64) || defined(__ORBIS__) || defined(__PROSPERO__) \8 || defined(SHORT_WCHAR) || (defined(_AIX) && !defined(__64BIT__))9  #define WCHAR_T_TYPE unsigned short10#elif defined(__aarch64__)11  // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD non-NetBSD.12  #if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)13    #define WCHAR_T_TYPE int14  #else15    #define WCHAR_T_TYPE unsigned int16  #endif17#elif defined(__arm) || defined(__MVS__) || (defined(_AIX) && defined(__64BIT__))18  #define WCHAR_T_TYPE unsigned int19#elif defined(__sun)20  #if defined(__LP64__)21    #define WCHAR_T_TYPE int22  #else23    #define WCHAR_T_TYPE long24  #endif25#else /* Solaris, Linux, non-arm64 macOS, ... */26  #define WCHAR_T_TYPE int27#endif28 29int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];30 31void foo(void) {32  WCHAR_T_TYPE t1[] = L"x";33  wchar_t tab[] = L"x";34  WCHAR_T_TYPE t2[] = "x";     // expected-error {{initializing wide char array with non-wide string literal}}35  char t3[] = L"x";   // expected-error {{initializing char array with wide string literal}}36}37