diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Lex/LiteralSupport.cpp | 14 |
2 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index d0e38a42473..52146d70335 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1607,14 +1607,15 @@ bool Lexer::LexNumericConstant(Token &Result, const char *CurPtr) { // If we have a hex FP constant, continue. if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p')) { - // Outside C99, we accept hexadecimal floating point numbers as a + // Outside C99 and C++17, we accept hexadecimal floating point numbers as a // not-quite-conforming extension. Only do so if this looks like it's // actually meant to be a hexfloat, and not if it has a ud-suffix. bool IsHexFloat = true; if (!LangOpts.C99) { if (!isHexaLiteral(BufferPtr, LangOpts)) IsHexFloat = false; - else if (std::find(BufferPtr, CurPtr, '_') != CurPtr) + else if (!getLangOpts().CPlusPlus1z && + std::find(BufferPtr, CurPtr, '_') != CurPtr) IsHexFloat = false; } if (IsHexFloat) diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 57494f87433..27c80b93015 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -797,7 +797,8 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { if (!HasSignificandDigits) { PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin), - diag::err_hexconstant_requires) << 1; + diag::err_hex_constant_requires) + << PP.getLangOpts().CPlusPlus << 1; hadError = true; return; } @@ -821,10 +822,15 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { s = first_non_digit; if (!PP.getLangOpts().HexFloats) - PP.Diag(TokLoc, diag::ext_hexconstant_invalid); + PP.Diag(TokLoc, PP.getLangOpts().CPlusPlus + ? diag::ext_hex_literal_invalid + : diag::ext_hex_constant_invalid); + else if (PP.getLangOpts().CPlusPlus1z) + PP.Diag(TokLoc, diag::warn_cxx1z_hex_literal); } else if (saw_period) { - PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin), - diag::err_hexconstant_requires) << 0; + PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin), + diag::err_hex_constant_requires) + << PP.getLangOpts().CPlusPlus << 0; hadError = true; } return; |

