diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/expr.c | 6 | ||||
-rw-r--r-- | libcpp/lex.c | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c index dd5611d..ab4a260 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -582,11 +582,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token, max_digit = c; } else if (DIGIT_SEP (c)) - { - if (seen_digit_sep) - SYNTAX_ERROR_AT (virtual_location, "adjacent digit separators"); - seen_digit_sep = true; - } + seen_digit_sep = true; else if (c == '.') { if (seen_digit_sep || DIGIT_SEP (*str)) diff --git a/libcpp/lex.c b/libcpp/lex.c index 06bcc31..9662f1b 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1548,18 +1548,28 @@ lex_number (cpp_reader *pfile, cpp_string *number, base = pfile->buffer->cur - 1; do { + const uchar *adj_digit_sep = NULL; cur = pfile->buffer->cur; /* N.B. ISIDNUM does not include $. */ - while (ISIDNUM (*cur) || *cur == '.' || DIGIT_SEP (*cur) - || VALID_SIGN (*cur, cur[-1])) + while (ISIDNUM (*cur) + || (*cur == '.' && !DIGIT_SEP (cur[-1])) + || DIGIT_SEP (*cur) + || (VALID_SIGN (*cur, cur[-1]) && !DIGIT_SEP (cur[-2]))) { NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur); + /* Adjacent digit separators do not form part of the pp-number syntax. + However, they can safely be diagnosed here as an error, since '' is + not a valid preprocessing token. */ + if (DIGIT_SEP (*cur) && DIGIT_SEP (cur[-1]) && !adj_digit_sep) + adj_digit_sep = cur; cur++; } /* A number can't end with a digit separator. */ while (cur > pfile->buffer->cur && DIGIT_SEP (cur[-1])) --cur; + if (adj_digit_sep && adj_digit_sep < cur) + cpp_error (pfile, CPP_DL_ERROR, "adjacent digit separators"); pfile->buffer->cur = cur; } |