]> granicus.if.org Git - clang/commitdiff
Tests for lexing of digit separators versus UCNs.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Feb 2014 20:13:19 +0000 (20:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Feb 2014 20:13:19 +0000 (20:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202534 91177308-0d34-0410-b5e6-96231b3b80d8

test/Lexer/cxx1y_digit_separators.cpp

index df0c26246161257411b5f7c64f9631defa1b531f..dcfb6d093fe18dd574415f1edc980a83a6a0077c 100644 (file)
@@ -43,3 +43,23 @@ static_assert(__LINE__ == 123456, "");
 #define M(x, ...) __VA_ARGS__
 constexpr int x = { M(1'2,3'4) };
 static_assert(x == 34, "");
+
+namespace UCNs {
+  // UCNs can appear before digit separators but not after.
+  int a = 0\u1234'5; // expected-error {{invalid suffix '\u1234'5' on integer constant}}
+  int b = 0'\u12345; // '; // expected-error {{expected ';'}}
+  constexpr int c {M(0\u1234'0,0'1)};
+  constexpr int d {M(00'\u1234,0'1)};
+  static_assert(c == 1, "");
+  static_assert(d == 0, "");
+}
+
+namespace UTF8 {
+  // extended characters can appear before digit separators but not after.
+  int a = 0ሴ'5; // expected-error {{invalid suffix 'ሴ'5' on integer constant}}
+  int b = 0'ሴ5; // '; // expected-error {{expected ';'}}
+  constexpr int c {M(0ሴ'0,0'1)};
+  constexpr int d {M(00'ሴ,0'1)};
+  static_assert(c == 1, "");
+  static_assert(d == 0, "");
+}