Daniel Dunbar | 80737ad | 2009-12-15 22:01:24 +0000 | [diff] [blame] | 1 | // RUN: %clang %s -fsyntax-only -Xclang -verify |
| 2 | // RUN: %clang %s -fsyntax-only -fshort-wchar -Xclang -verify -DSHORT_WCHAR |
Benjamin Kramer | 947e00d | 2009-11-17 14:02:16 +0000 | [diff] [blame] | 3 | |
| 4 | typedef __WCHAR_TYPE__ wchar_t; |
| 5 | |
John Thompson | a6fda12 | 2009-11-05 20:14:16 +0000 | [diff] [blame] | 6 | #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \ |
| 7 | || defined(_M_X64) || defined(SHORT_WCHAR) |
| 8 | #define WCHAR_T_TYPE unsigned short |
Edward O'Callaghan | 11ac3f5 | 2009-11-22 16:21:47 +0000 | [diff] [blame] | 9 | #elif defined(__sun) || defined(__AuroraUX__) |
| 10 | #define WCHAR_T_TYPE long |
| 11 | #else /* Solaris or AuroraUX. */ |
John Thompson | a6fda12 | 2009-11-05 20:14:16 +0000 | [diff] [blame] | 12 | #define WCHAR_T_TYPE int |
| 13 | #endif |
| 14 | |
Chris Lattner | 19753cf | 2009-02-26 23:36:02 +0000 | [diff] [blame] | 15 | int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1]; |
John Thompson | a6fda12 | 2009-11-05 20:14:16 +0000 | [diff] [blame] | 16 | |
Chris Lattner | 19753cf | 2009-02-26 23:36:02 +0000 | [diff] [blame] | 17 | void foo() { |
John Thompson | a6fda12 | 2009-11-05 20:14:16 +0000 | [diff] [blame] | 18 | WCHAR_T_TYPE t1[] = L"x"; |
Chris Lattner | 19753cf | 2009-02-26 23:36:02 +0000 | [diff] [blame] | 19 | wchar_t tab[] = L"x"; |
Eli Friedman | cfdc81a | 2009-12-19 08:11:05 +0000 | [diff] [blame] | 20 | WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializer}} |
| 21 | char t3[] = L"x"; // expected-error {{initializer}} |
Chris Lattner | 19753cf | 2009-02-26 23:36:02 +0000 | [diff] [blame] | 22 | } |