diff options
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 14 | 
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 637a08f..b8202ea 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -258,6 +258,7 @@ static bool isBuiltinHeaderName(StringRef FileName) {             .Case("stdarg.h", true)             .Case("stdatomic.h", true)             .Case("stdbool.h", true) +           .Case("stdckdint.h", true)             .Case("stdcountof.h", true)             .Case("stddef.h", true)             .Case("stdint.h", true) diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index dd80ae5..5efa4b5 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1735,7 +1735,19 @@ 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. +    constexpr uint32_t MaxPosValue = std::numeric_limits<int32_t>::max(); +    if (CounterValue > MaxPosValue) { +      Diag(Tok.getLocation(), diag::err_counter_overflow); +      // Retain the maximal value so we don't issue conversion-related +      // diagnostics by overflowing into a long long. While this does produce +      // a duplicate value, there's no way to ignore this error so there's no +      // translation anyway. +      CounterValue = MaxPosValue; +    }      OS << CounterValue++;      Tok.setKind(tok::numeric_constant);    } else if (II == Ident__has_feature) {  | 
