From 3ec6b84545c594625bf2277ddf01493e98c02c15 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 29 Aug 2016 20:43:38 +0000 Subject: Fix or suppress GCC warnings during build. Summary: Currently a number of GCC warnings are emitted when building libc++. This patch fixes or ignores all of them. The primary changes are: * Work around strict aliasing issues in `typeinfo::hash_code()` by using __attribute__((may_alias)). However I think a non-aliasing `hash_code()` implementation is possible. Further investigation needed. * Add `_LIBCPP_UNREACHABLE()` to switch in `strstream.cpp` to avoid -Wpotentially-uninitialized. * Fix -Wunused-value warning in `__all` by adding a void cast. * Ignore -Wattributes for now. There are a number of real attribute issues when using GCC but enabling the warning is too noisy. * Ignore -Wliteral-suffix since it warns about the use of reserved identifiers. Note Only GCC 7.0 supports disabling this warning. * Ignore -Wc++14-compat since it warns about the sized new/delete overloads. Reviewers: EricWF Differential Revision: https://reviews.llvm.org/D24003 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@280007 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c6c31c4..d0ed9df5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,10 +322,19 @@ add_compile_flags_if_supported(-nostdinc++) # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( - -Wall -W -Wwrite-strings - -Wno-unused-parameter -Wno-long-long -Wno-user-defined-literals - -Wno-covered-switch-default + -Wall -Wextra -W -Wwrite-strings + -Wno-unused-parameter -Wno-long-long -Werror=return-type) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + add_compile_flags_if_supported( + -Wno-user-defined-literals + -Wno-covered-switch-default) +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + add_compile_flags_if_supported( + -Wno-attributes # FIXME: Fix -Wattribute warnings. + -Wno-literal-suffix + -Wno-c++14-compat) +endif() if (LIBCXX_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) -- cgit v1.2.3