xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/ms-wchar.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // C++ mode with -fno-wchar works the same as C mode for wchar_t.
4f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc wchar_t f(); // expected-error{{unknown type name 'wchar_t'}}
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc // __wchar_t is available as an MS extension.
9f4a2713aSLionel Sambuc __wchar_t g = L'a'; // expected-note {{previous}}
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc // __wchar_t is a distinct type, separate from the target's integer type for wide chars.
12f4a2713aSLionel Sambuc unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}}
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc // The type of a wide string literal is actually not __wchar_t.
15*0a6a1f1dSLionel Sambuc __wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list{{$}}}}
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // Do not suggest initializing with a string here, because it would not work.
18*0a6a1f1dSLionel Sambuc __wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list{{$}}}}
19