[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 28 11:29:27 PDT 2025


=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/135864 at github.com>


================
@@ -1,6 +1,14 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -Wformat-pedantic -fblocks %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -Wformat-pedantic -fblocks -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -Wformat-pedantic -fblocks -std=c++20 %s
+
+#if __cplusplus >= 202000l
+// expected-note at -6{{format string computed from non-literal expression}}
----------------
AaronBallman wrote:

Better to use `// #bookmark` and then `expected-note@#bookmark` closer to where the diagnostic comes from which generates the note. (My immediate question was "what's special about C++20?" when the answer was "the code which generates the note only runs in C++20".)

https://github.com/llvm/llvm-project/pull/135864


More information about the cfe-commits mailing list