[PATCH] D41834: [Lex] Fix handling numerical literals ending with ' and signed exponent.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 17:20:04 PST 2018
rsmith added a comment.
The lexer is doing the right thing; per the C++ lexical rules, the `+1` is not part of the token in this case.
I don't think this fix is in the right place; we will still examine characters after the end of the literal, even with this applied, and that doesn't seem right to me (even though the literal parser is constructed in such a way that it is valid to do so, as long as it doesn't read past a nul byte). It looks like the problem is that `NumericLiteralParser::ParseDecimalOrOctalCommon` will examine `*s` in cases where it might point past the end of the literal; changing
if (*s == '+' || *s == '-') s++; // sign
to
if (s != ThisTokEnd && (*s == '+' || *s == '-')) s++; // sign
would seem appropriate. But I think I'd be most in favor of that change plus your change plus a change to suppress the "no digits in suffix" error if we've already had an error. Seem reasonable?
https://reviews.llvm.org/D41834
More information about the cfe-commits
mailing list