Skip to content

Commit 48a23a8

Browse files
authored
Merge pull request #39901 from al45tair/problem/84571859-2
[Stdlib] Enable -Wformat-nonliteral and make it an error.
2 parents b8ed3e0 + b5b702e commit 48a23a8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
3838
list(APPEND SWIFT_RUNTIME_CORE_CXX_FLAGS "-xc++")
3939
endif()
4040

41+
# We should avoid non-literals in format strings, or appropriately mark
42+
# functions.
43+
check_cxx_compiler_flag("-Wformat-nonliteral -Werror=format-nonliteral" CXX_SUPPORTS_FORMAT_NONLITERAL_WARNING)
44+
if (CXX_SUPPORTS_FORMAT_NONLITERAL_WARNING)
45+
list(APPEND SWIFT_RUNTIME_CORE_CXX_FLAGS "-Wformat-nonliteral"
46+
"-Werror=format-nonliteral")
47+
endif()
48+
4149
# C++ code in the runtime and standard library should generally avoid
4250
# introducing static constructors or destructors.
4351
check_cxx_compiler_flag("-Wglobal-constructors -Werror=global-constructors" CXX_SUPPORTS_GLOBAL_CONSTRUCTORS_WARNING)

0 commit comments

Comments
 (0)