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