Skip to content

Commit 7129a6a

Browse files
committed
Use a named constant; NFC
1 parent 1d0a459 commit 7129a6a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,13 +1741,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
17411741
getLangOpts().C2y ? diag::warn_counter : diag::ext_counter);
17421742
// __COUNTER__ expands to a simple numeric value that must be less than
17431743
// 2147483647.
1744-
if (CounterValue > 2147483647) {
1744+
constexpr unsigned long MaxPosValue = std::numeric_limits<int32_t>::max();
1745+
if (CounterValue > MaxPosValue) {
17451746
Diag(Tok.getLocation(), diag::err_counter_overflow);
17461747
// Retain the maximal value so we don't issue conversion-related
17471748
// diagnostics by overflowing into a long long. While this does produce
17481749
// a duplicate value, there's no way to ignore this error so there's no
17491750
// translation anyway.
1750-
CounterValue = 2147483647;
1751+
CounterValue = MaxPosValue;
17511752
}
17521753
OS << CounterValue++;
17531754
Tok.setKind(tok::numeric_constant);

0 commit comments

Comments
 (0)