[clang] [C2y] Support WG14 N3457, the __COUNTER__ macro (PR #162662)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 9 08:22:13 PDT 2025
================
@@ -1737,7 +1737,18 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
}
} else if (II == Ident__COUNTER__) {
- // __COUNTER__ expands to a simple numeric value.
+ Diag(Tok.getLocation(),
+ getLangOpts().C2y ? diag::warn_counter : diag::ext_counter);
+ // __COUNTER__ expands to a simple numeric value that must be less than
+ // 2147483647.
+ if (CounterValue > 2147483647) {
----------------
Fznamznon wrote:
Maybe makes sense to put `2147483647` into a constant somewhere?
https://github.com/llvm/llvm-project/pull/162662
More information about the cfe-commits
mailing list