[cfe-commits] r147438 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/constexpr-printing.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Jan 2 10:14:06 PST 2012


Author: rsmith
Date: Mon Jan  2 12:14:06 2012
New Revision: 147438

URL: http://llvm.org/viewvc/llvm-project?rev=147438&view=rev
Log:
Add assertion to char32_t that the value is valid, as suggested by Jordy Rose.
Add a test that such characters don't make it through to StringLiteral objects
in error recovery.

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/test/SemaCXX/constexpr-printing.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=147438&r1=147437&r2=147438&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Jan  2 12:14:06 2012
@@ -717,7 +717,7 @@
     default:
       // FIXME: Is this the best way to print wchar_t?
       if (Char > 0xff) {
-        // char32_t values are <= 0x10ffff.
+        assert(Char <= 0x10ffff && "invalid unicode codepoint");
         if (Char > 0xffff)
           OS << "\\U00"
              << Hex[(Char >> 20) & 15]

Modified: cfe/trunk/test/SemaCXX/constexpr-printing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-printing.cpp?rev=147438&r1=147437&r2=147438&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-printing.cpp Mon Jan  2 12:14:06 2012
@@ -83,7 +83,9 @@
   expected-error {{}} expected-note {{u8"test\000\\\"\t\a\b\234"}}
 constexpr char16_t c16 = get(u"test\0\\\"\t\a\b\234\u1234"); // \
   expected-error {{}} expected-note {{u"test\000\\\"\t\a\b\234\u1234"}}
-constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U00101234"); // \
-  expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U00101234"}}
+constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U0010ffff"); // \
+  expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"}}
 constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234"); // \
   expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\u1234"}}
+
+constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}}





More information about the cfe-commits mailing list