1 // RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s
2 wchar_t x; // expected-error {{unknown type name 'wchar_t'}}
3
4 typedef unsigned short wchar_t;
5 void foo(const wchar_t* x);
6
bar()7 void bar() {
8 foo(L"wide string literal");
9 }
10
11 void foo1(wchar_t * t = L"");
12 // expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}}
13
14 short *a = L"";
15 // expected-error@-1 {{cannot initialize a variable of type 'short *' with an lvalue of type 'const unsigned short [1]'}}
16 char *b = L"";
17 // expected-error@-1 {{cannot initialize a variable of type 'char *' with an lvalue of type 'const unsigned short [1]'}}
18
19 // NOTE: MSVC allows deprecated conversion in conditional expression if at least
20 // one of the operand is a string literal but Clang doesn't allow it.
21 wchar_t *c = true ? L"a" : L"";
22 // expected-error@-1 {{cannot initialize a variable of type 'wchar_t *' (aka 'unsigned short *') with}}
23
24 const wchar_t *d1 = 0;
25 const wchar_t *d2 = 0;
26 wchar_t *d = true ? d1 : d2;
27 // expected-error@-1 {{cannot initialize a variable of type 'wchar_t *' (aka 'unsigned short *') with}}
28
29 wchar_t* e = (const wchar_t*)L"";
30 // expected-error@-1 {{cannot initialize a variable of type 'wchar_t *' (aka 'unsigned short *') with an rvalue of type 'const wchar_t *' (aka 'const unsigned short *')}}
31