diff options
author | David Benjamin <davidben@google.com> | 2022-10-14 08:44:15 -0400 |
---|---|---|
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-14 18:38:02 +0000 |
commit | 7d1fc2b014a940e4e9ecd4660146c5cc2accad9b (patch) | |
tree | 1012098af501f851e6149f3fba3ed0d9b9ee2ef8 /CMakeLists.txt | |
parent | 58f728eaecf9d1152df4977e50f90375e05c486d (diff) | |
download | boringssl-7d1fc2b014a940e4e9ecd4660146c5cc2accad9b.zip boringssl-7d1fc2b014a940e4e9ecd4660146c5cc2accad9b.tar.gz boringssl-7d1fc2b014a940e4e9ecd4660146c5cc2accad9b.tar.bz2 |
Enable -Wstring-concatenation and silence warning.
Newer versions of Clang have a warning to detect "suspicious" uses of
string concatenation, where they think a comma or so was missing. It
flags a false positive in x509_test.cc, which we can silence with
parentheses. Fuchsia builds with this warning enabled, so enable it to
catch future instances.
I couldn't find official documentation on when this was added, but
empirically it's in my clang-12 but not my clang-11. That's recent
enough that adding a version check seems prudent. Unfortunately,
version-detecting Clang is complex because AppleClang uses completely
different versions. There's a handy table on Wikipedia that maps them.
Change-Id: I503c21d39bb5c68dda9bda6da693c7208f3af561
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/54785
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0864958..69169c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,6 +160,16 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CLANG) set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object") endif() + # -Wstring-concatenation was added in Clang 12.0.0, which corresponds to + # AppleClang 13.0.0 per the table in + # https://en.wikipedia.org/wiki/Xcode#Toolchain_versions + if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0") OR + (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0")) + set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wstring-concatenation") + endif() + if(CLANG OR CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0") set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough") endif() |