[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 18 08:23:32 PDT 2025
================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++2c %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// expected-no-diagnostics
+
+// This file intentionally does not end with a newline. CWG787 made this
+// well-defined behavior.
+
+// cwg787: 3.0
----------------
Endilll wrote:
> Because we accept the code and do the right thing with it?
`-pedantic-errors` reject it up until your patch, IIUC.
> AIUI, the Core Issue was that it went from UB to well-defined behavior, but we diagnose well-defined behavior all the time; it doesn't mean we don't implement the DR, right? (I'm fine with changing the marking, it just wasn't clear to me that any changes were needed to conform to the DR.)
My reading of changes to [lex.phases] in [CWG787](https://cplusplus.github.io/CWG/issues/787.html) doesn't leave a room for issuing a diagnostic while remaining conformant. Maybe this is the source of the confusion. When we determine availability of a DR in older version, we check them against our current understanding of what the behavior should be. In this case, I think it is that no diagnostic should be issued. Which means `// cwg787: 21` is the correct status here.
Let me know if I'm missing something.
https://github.com/llvm/llvm-project/pull/131794
More information about the cfe-commits
mailing list