summaryrefslogtreecommitdiff
path: root/lib/Lex/LiteralSupport.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-09 22:34:35 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-09 22:34:35 +0000
commitd2a788ad627f58ab7a283527a4a2c58102740410 (patch)
tree2f28e3045f10ff8d0b1b08494cff01e327f3c300 /lib/Lex/LiteralSupport.cpp
parentadee5efbad8218f61f41d06e1aa315e34da95bc9 (diff)
downloadclang-d2a788ad627f58ab7a283527a4a2c58102740410.tar.gz
PR26349: correctly check whether a digit sequence is empty in the presence of digit separators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
-rw-r--r--lib/Lex/LiteralSupport.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index fb9d63b940..0c0626c8a8 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -700,7 +700,7 @@ void NumericLiteralParser::ParseDecimalOrOctalCommon(SourceLocation TokLoc){
saw_exponent = true;
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
- if (first_non_digit != s) {
+ if (containsDigits(s, first_non_digit)) {
checkSeparator(TokLoc, s, CSK_BeforeDigits);
s = first_non_digit;
} else {
@@ -771,19 +771,21 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
radix = 16;
DigitsBegin = s;
s = SkipHexDigits(s);
- bool noSignificand = (s == DigitsBegin);
+ bool HasSignificandDigits = containsDigits(DigitsBegin, s);
if (s == ThisTokEnd) {
// Done.
} else if (*s == '.') {
s++;
saw_period = true;
const char *floatDigitsBegin = s;
- checkSeparator(TokLoc, s, CSK_BeforeDigits);
s = SkipHexDigits(s);
- noSignificand &= (floatDigitsBegin == s);
+ if (containsDigits(floatDigitsBegin, s))
+ HasSignificandDigits = true;
+ if (HasSignificandDigits)
+ checkSeparator(TokLoc, floatDigitsBegin, CSK_BeforeDigits);
}
- if (noSignificand) {
+ if (!HasSignificandDigits) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
diag::err_hexconstant_requires) << 1;
hadError = true;
@@ -799,7 +801,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
saw_exponent = true;
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
- if (first_non_digit == s) {
+ if (!containsDigits(s, first_non_digit)) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
diag::err_exponent_has_no_digits);
hadError = true;