blob: ed6649a31d981b2b448281b708e4180afa65c0e9 [file] [log] [blame]
Daniel Dunbar633d5b32009-11-17 10:14:55 +00001// RUN: clang %s -fsyntax-only -Xclang -verify
2// RUN: clang %s -fsyntax-only -fshort-wchar -Xclang -verify -DSHORT_WCHAR
Benjamin Kramerb70e4ab2009-11-17 14:02:16 +00003
4typedef __WCHAR_TYPE__ wchar_t;
5
John Thompsoned4e2952009-11-05 20:14:16 +00006#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
7 || defined(_M_X64) || defined(SHORT_WCHAR)
8 #define WCHAR_T_TYPE unsigned short
Edward O'Callaghan0825f092009-11-22 16:21:47 +00009#elif defined(__sun) || defined(__AuroraUX__)
10 #define WCHAR_T_TYPE long
11#else /* Solaris or AuroraUX. */
John Thompsoned4e2952009-11-05 20:14:16 +000012 #define WCHAR_T_TYPE int
13#endif
14
Chris Lattner7ec0bb62009-02-26 23:36:02 +000015int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
John Thompsoned4e2952009-11-05 20:14:16 +000016
Chris Lattner7ec0bb62009-02-26 23:36:02 +000017void foo() {
John Thompsoned4e2952009-11-05 20:14:16 +000018 WCHAR_T_TYPE t1[] = L"x";
Chris Lattner7ec0bb62009-02-26 23:36:02 +000019 wchar_t tab[] = L"x";
John Thompsoned4e2952009-11-05 20:14:16 +000020 WCHAR_T_TYPE t2[] = "x"; // expected-error {{initialization}}
Chris Lattner7ec0bb62009-02-26 23:36:02 +000021 char t3[] = L"x"; // expected-error {{initialization}}
22}