diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-05-15 11:03:04 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-05-15 11:03:04 +0000 |
commit | 0ff5074f37a66bca244a9d5d0da050ff68693ce2 (patch) | |
tree | 9c977823d274f1827c9c00fd0c3521eb03c6e444 /test/Lexer/char-literal.cpp | |
parent | 33f4b90476f24d269cac04915d951d8f05bd3a77 (diff) | |
download | clang-0ff5074f37a66bca244a9d5d0da050ff68693ce2.tar.gz |
Better diagnostics for string initialization.
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Lexer/char-literal.cpp')
-rw-r--r-- | test/Lexer/char-literal.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp index b2fab34e44..1cd14a9b01 100644 --- a/test/Lexer/char-literal.cpp +++ b/test/Lexer/char-literal.cpp @@ -36,8 +36,4 @@ char16_t p[2] = u"\U0000FFFF"; char16_t q[2] = u"\U00010000"; #ifdef __cplusplus // expected-error@-2 {{too long}} -#else -// FIXME: The above should be accepted in C11 mode. -// expected-error@-6 {{must be an initializer list}} -// expected-error@-6 {{must be an initializer list}} #endif |