This commit improves Clang's diagnostics for string initialization.
Where it would previously say:
/tmp/a.c:3:9: error: array initializer must be an initializer list
wchar_t s[] = "Hi";
^
/tmp/a.c:4:6: error: array initializer must be an initializer list or string literal
char t[] = L"Hi";
^
It will now say
/tmp/a.c:3:9: error: initializing wide char array with non-wide string literal
wchar_t s[] = "Hi";
^
/tmp/a.c:4:6: error: initializing char array with wide string literal
char t[] = L"Hi";
^
As a bonus, it also fixes the fact that Clang would previously reject
this valid C11 code:
char16_t s[] = u"hi";
char32_t t[] = U"hi";
because it would only recognize the built-in types for char16_t and
char32_t, which do not exist in C.
llvm-svn: 181880
13 lines
542 B
C++
13 lines
542 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
|
|
|
|
wchar_t f();
|
|
__wchar_t f(); // No error, wchar_t and __wchar_t are the same type.
|
|
|
|
__wchar_t g = L'a';
|
|
__wchar_t s[] = L"Hello world!";
|
|
|
|
unsigned short t[] = L"Hello world!"; // expected-error{{array initializer must be an initializer list}}
|
|
|
|
wchar_t u[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
|
|
__wchar_t v[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
|