mirror of https://github.com/microsoft/clang.git
Unify diagnostics for \x, \u, and \U without any following hex digits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173368 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b3326527e
commit
5209e2bc4d
|
@ -99,8 +99,7 @@ def ext_four_char_character_literal : Extension<
|
|||
def ext_nonstandard_escape : Extension<
|
||||
"use of non-standard escape character '\\%0'">;
|
||||
def ext_unknown_escape : ExtWarn<"unknown escape sequence '\\%0'">;
|
||||
def err_hex_escape_no_digits : Error<"\\x used with no following hex digits">;
|
||||
def err_ucn_escape_no_digits : Error<"\\u used with no following hex digits">;
|
||||
def err_hex_escape_no_digits : Error<"\\%0 used with no following hex digits">;
|
||||
def err_ucn_escape_invalid : Error<"invalid universal character">;
|
||||
def err_ucn_escape_incomplete : Error<"incomplete universal character name">;
|
||||
def err_ucn_escape_basic_scs : Error<
|
||||
|
|
|
@ -130,7 +130,7 @@ static unsigned ProcessCharEscape(const char *ThisTokBegin,
|
|||
if (ThisTokBuf == ThisTokEnd || !isxdigit(*ThisTokBuf)) {
|
||||
if (Diags)
|
||||
Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf,
|
||||
diag::err_hex_escape_no_digits);
|
||||
diag::err_hex_escape_no_digits) << "x";
|
||||
HadError = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ static bool ProcessUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
|
|||
if (ThisTokBuf == ThisTokEnd || !isxdigit(*ThisTokBuf)) {
|
||||
if (Diags)
|
||||
Diag(Diags, Features, Loc, ThisTokBegin, UcnBegin, ThisTokBuf,
|
||||
diag::err_ucn_escape_no_digits);
|
||||
diag::err_hex_escape_no_digits) << StringRef(&ThisTokBuf[-1], 1);
|
||||
return false;
|
||||
}
|
||||
UcnLen = (ThisTokBuf[-1] == 'u' ? 4 : 8);
|
||||
|
|
|
@ -8,7 +8,7 @@ int main(void) {
|
|||
printf("%s (%zd)\n", "hello \u2192 \u2603 \u2190 world", sizeof("hello \u2192 \u2603 \u2190 world"));
|
||||
printf("%s (%zd)\n", "\U00010400\U0001D12B", sizeof("\U00010400\U0001D12B"));
|
||||
// Some error conditions...
|
||||
printf("%s\n", "\U"); // expected-error{{\u used with no following hex digits}}
|
||||
printf("%s\n", "\U"); // expected-error{{\U used with no following hex digits}}
|
||||
printf("%s\n", "\U00"); // expected-error{{incomplete universal character name}}
|
||||
printf("%s\n", "\U0001"); // expected-error{{incomplete universal character name}}
|
||||
printf("%s\n", "\u0001"); // expected-error{{universal character name refers to a control character}}
|
||||
|
|
Loading…
Reference in New Issue