[cfe-commits] r173368 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/LiteralSupport.cpp test/Sema/ucn-cstring.c

Jordan Rose jordan_rose at apple.com
Thu Jan 24 12:50:13 PST 2013


Author: jrose
Date: Thu Jan 24 14:50:13 2013
New Revision: 173368

URL: http://llvm.org/viewvc/llvm-project?rev=173368&view=rev
Log:
Unify diagnostics for \x, \u, and \U without any following hex digits.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/lib/Lex/LiteralSupport.cpp
    cfe/trunk/test/Sema/ucn-cstring.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=173368&r1=173367&r2=173368&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Jan 24 14:50:13 2013
@@ -99,8 +99,7 @@
 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<

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=173368&r1=173367&r2=173368&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Thu Jan 24 14:50:13 2013
@@ -130,7 +130,7 @@
     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 @@
   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);

Modified: cfe/trunk/test/Sema/ucn-cstring.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ucn-cstring.c?rev=173368&r1=173367&r2=173368&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ucn-cstring.c (original)
+++ cfe/trunk/test/Sema/ucn-cstring.c Thu Jan 24 14:50:13 2013
@@ -8,7 +8,7 @@
   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}}





More information about the cfe-commits mailing list