summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-03-04 22:32:06 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-03-04 22:32:06 +0000
commit560a3579b29a07c729d841acaa1d3371b5fc9b71 (patch)
tree38d1d789e15125216b8b6d846818963a982d51d8 /clang/lib/Lex
parentac92893a93618d66416afbdd86db1ce99543e3e4 (diff)
downloadbcm5719-llvm-560a3579b29a07c729d841acaa1d3371b5fc9b71.tar.gz
bcm5719-llvm-560a3579b29a07c729d841acaa1d3371b5fc9b71.zip
Update diagnostics now that hexadecimal literals look likely to be part of C++17.
llvm-svn: 262753
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/Lexer.cpp5
-rw-r--r--clang/lib/Lex/LiteralSupport.cpp14
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;
OpenPOWER on IntegriCloud