]> granicus.if.org Git - clang/commitdiff
Add assertion to char32_t that the value is valid, as suggested by Jordy Rose.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 2 Jan 2012 18:14:06 +0000 (18:14 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 2 Jan 2012 18:14:06 +0000 (18:14 +0000)
Add a test that such characters don't make it through to StringLiteral objects
in error recovery.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147438 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp
test/SemaCXX/constexpr-printing.cpp

index 6408c879fa20fee54941a92413cd8fb95674e6f8..836f192aeb1cbc1846fccb6d7e724695a76b9c34 100644 (file)
@@ -717,7 +717,7 @@ void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
     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]
index a648fab42e368b0318af765852bc10d94a90348d..03768c09fb9c57bda739bd3013bf90d32e9a5233 100644 (file)
@@ -83,7 +83,9 @@ constexpr char c8 = get(u8"test\0\\\"\t\a\b\234"); // \
   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}}