]> granicus.if.org Git - clang/commitdiff
Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a ...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Sep 2013 18:13:20 +0000 (18:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Sep 2013 18:13:20 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191443 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp
lib/Lex/PPDirectives.cpp
test/Lexer/cxx1y_digit_separators.cpp

index ee46895abd46ec7eb86931adad44e2701c64327a..3817afe75d1383947d067975f513f76e22e69bf8 100644 (file)
@@ -1610,7 +1610,7 @@ bool Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
   if (C == '\'' && getLangOpts().CPlusPlus1y) {
     unsigned NextSize;
     char Next = getCharAndSizeNoWarn(CurPtr + Size, NextSize, getLangOpts());
-    if (isAlphanumeric(Next)) {
+    if (isIdentifierBody(Next)) {
       if (!isLexingRawMode())
         Diag(CurPtr, diag::warn_cxx11_compat_digit_separator);
       CurPtr = ConsumeChar(CurPtr, Size, Result);
index 759199259614b5342a72b5fa1c9a3aed757de74b..99b30c67ac36aa2a26df634d5b3e09d843cc2de0 100644 (file)
@@ -911,6 +911,11 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
   // here.
   Val = 0;
   for (unsigned i = 0; i != ActualLength; ++i) {
+    // C++1y [lex.fcon]p1:
+    //   Optional separating single quotes in a digit-sequence are ignored
+    if (DigitTokBegin[i] == '\'')
+      continue;
+
     if (!isDigit(DigitTokBegin[i])) {
       PP.Diag(PP.AdvanceToTokenCharacter(DigitTok.getLocation(), i),
               diag::err_pp_line_digit_sequence) << IsGNULineDirective;
index 2c83b1fcdba7c13febd9a7f262b24fbb6b182724..59ad5d30f48e2e26b375c22f437c74c4fc9d25a7 100644 (file)
@@ -3,6 +3,8 @@
 int operator""ms(unsigned long long); // expected-warning {{reserved}}
 float operator""ms(long double); // expected-warning {{reserved}}
 
+int operator""_foo(unsigned long long);
+
 namespace integral {
   static_assert(1'2'3 == 12'3, "");
   static_assert(1'000'000 == 0xf'4240, "");
@@ -17,8 +19,7 @@ namespace integral {
   int f = 0b'1010; // expected-error {{invalid digit 'b' in octal}}
   int g = 123'ms; // expected-error {{digit separator cannot appear at end of digit sequence}}
 
-  // FIXME: not yet known if _ after ' will be permitted.
-  int z = 0'123'_foo; //'; // expected-error {{expected ';'}}
+  int z = 0'123'_foo; //'; // expected-error {{cannot appear at end of digit seq}}
 }
 
 namespace floating {
@@ -32,3 +33,6 @@ namespace floating {
   float e = 1e'1; // expected-error {{digit separator cannot appear at start of digit sequence}}
   float f = 1e1'ms; // expected-error {{digit separator cannot appear at end of digit sequence}}
 }
+
+#line 123'456
+static_assert(__LINE__ == 123456, "");