File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments