r191443 - Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a #line directive.

Richard Smith richard-llvm at metafoo.co.uk
Thu Sep 26 11:13:20 PDT 2013


Author: rsmith
Date: Thu Sep 26 13:13:20 2013
New Revision: 191443

URL: http://llvm.org/viewvc/llvm-project?rev=191443&view=rev
Log:
Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a #line directive.

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=191443&r1=191442&r2=191443&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Sep 26 13:13:20 2013
@@ -1610,7 +1610,7 @@ bool Lexer::LexNumericConstant(Token &Re
   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);

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=191443&r1=191442&r2=191443&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Sep 26 13:13:20 2013
@@ -911,6 +911,11 @@ static bool GetLineValue(Token &DigitTok
   // 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;

Modified: cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp?rev=191443&r1=191442&r2=191443&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp (original)
+++ cfe/trunk/test/Lexer/cxx1y_digit_separators.cpp Thu Sep 26 13:13:20 2013
@@ -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, "");





More information about the cfe-commits mailing list