forked from OSchip/llvm-project
Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a #line directive.
llvm-svn: 191443
This commit is contained in:
parent
af1acd9a5e
commit
7f2707a7f4
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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, "");
|
||||
|
|
Loading…
Reference in New Issue