-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[C2y] Handle FP-suffixes on prefixed octals (#141230) #141695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1420,7 +1420,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { | |
} | ||
|
||
// Parse a potential octal literal prefix. | ||
bool SawOctalPrefix = false, IsSingleZero = false; | ||
bool IsSingleZero = false; | ||
if ((c1 == 'O' || c1 == 'o') && (s[1] >= '0' && s[1] <= '7')) { | ||
unsigned DiagId; | ||
if (LangOpts.C2y) | ||
|
@@ -1432,14 +1432,26 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { | |
Diags.Report(TokLoc, DiagId); | ||
++s; | ||
DigitsBegin = s; | ||
SawOctalPrefix = true; | ||
radix = 8; | ||
s = SkipOctalDigits(s); | ||
if (s == ThisTokEnd) { | ||
// Done | ||
} else if ((isHexDigit(*s) && *s != 'e' && *s != 'E' && *s != '.') && | ||
!isValidUDSuffix(LangOpts, StringRef(s, ThisTokEnd - s))) { | ||
Diags.Report(Lexer::AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin, SM, | ||
LangOpts), | ||
diag::err_invalid_digit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please extract |
||
<< StringRef(s, 1) << 1; | ||
hadError = true; | ||
} | ||
// Other suffixes will be diagnosed by the caller. | ||
return; | ||
} | ||
|
||
auto _ = llvm::make_scope_exit([&] { | ||
// If we still have an octal value but we did not see an octal prefix, | ||
// diagnose as being an obsolescent feature starting in C2y. | ||
if (radix == 8 && LangOpts.C2y && !SawOctalPrefix && !hadError && | ||
!IsSingleZero) | ||
if (radix == 8 && LangOpts.C2y && !hadError && !IsSingleZero) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have tests showing |
||
Diags.Report(TokLoc, diag::warn_unprefixed_octal_deprecated); | ||
}); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.