From 6979c7e8eb0c96cbf57bd8f657d59a50f0487fcf Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 4 Dec 2017 17:19:49 -0500 Subject: [PATCH] Disable Clang -Wtautological-constant-compare. This is a recent Clang warning, but it's far too aggressive. The earlier unsigned long silliness was worth fixing, but it otherwise complains on 32-bit platforms with: if (some_size_t > 0xffffffff) { ... } which is unreasonable as, on 64-bit platforms, this check is meaningful and requiring the programmer add ifdefs is error-prone. This matches Chromium in https://crbug.com/767059. Bug: chromium:767059 Change-Id: I0bb0f3a4b60f222e9d1b3c569471fbcf5518caed Reviewed-on: https://boringssl-review.googlesource.com/23845 Commit-Queue: David Benjamin CQ-Verified: CQ bot account: commit-bot@chromium.org Reviewed-by: Adam Langley --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb8717ac..6674a419 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required (VERSION 2.8.11) +# Report AppleClang separately from Clang. Their version numbers are different. +# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) +endif() + # Defer enabling C and CXX languages. project (BoringSSL NONE) @@ -63,6 +69,18 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CLANG) set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object") endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND + NOT "6.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION) + # Clang's -Wtautological-constant-compare is far too aggressive and does not + # account for, say, wanting the same code to work on both 32-bit and 64-bit + # platforms. + # + # Note "Clang" and "AppleClang" version differently, so we check for an + # exact match on the COMPILER_ID. As of writing, the warning is not in any + # release of AppleClang yet. + set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-tautological-constant-compare -Wtautological-constant-out-of-range-compare") + endif() + if(CLANG OR NOT "7.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION) set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough") endif()