[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 18 06:20:34 PDT 2025
================
@@ -3194,18 +3194,12 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
SourceLocation EndLoc = getSourceLocation(BufferEnd);
unsigned DiagID = diag::warn_no_newline_eof;
- if (LangOpts.CPlusPlus11) {
- // C++11 [lex.phases] 2.2 p2
- // Prefer the C++98 pedantic compatibility warning over the generic,
- // non-extension, user-requested "missing newline at EOF" warning.
- if (!Diags.isIgnored(diag::warn_cxx98_compat_no_newline_eof, EndLoc))
- DiagID = diag::warn_cxx98_compat_no_newline_eof;
- } else {
- // This is conforming in C2y, but is an extension in earlier language
- // modes.
- if (!LangOpts.C2y)
- DiagID = diag::ext_no_newline_eof;
- }
+ // C++11 [lex.phases] 2.2 p2
+ // Prefer the C++98 pedantic compatibility warning over the generic,
+ // non-extension, user-requested "missing newline at EOF" warning.
+ if (LangOpts.CPlusPlus11 &&
----------------
AaronBallman wrote:
It is a DR in C++11 so it applies to C++98 as well. What this block is doing is basically saying "if the user passed `-Wc++98-compat-pedantic` prefer issuing that diagnostic over the `-Wnewline-eof` diagnostic."
https://github.com/llvm/llvm-project/pull/131794
More information about the cfe-commits
mailing list