[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 18:35:21 PDT 2020
sammccall created this revision.
sammccall added reviewers: kadircet, uabelho, bjope.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
Currently this warning is on for both clang and GCC, when building clang.
It's off for the rest of LLVM, so my sense is it isn't that vital.
Clang's version seems to be OK: it warns if you're declaring a method that's
virtual in the base, but not overriding.
GCC's version warns whenever there's name hiding, even if you are overriding
something. It fires on this legitimate pattern:
class Base {
virtual void foo(); // to be overridden
void foo(int); // implemented in terms of foo()
};
foo(int) is hidden in derived classes, but foo(int) is used polymorphically
through Base* and works fine there.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82617
Files:
clang/CMakeLists.txt
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -393,8 +393,11 @@
# Add appropriate flags for GCC
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
- if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Clang's version of -Woverloaded-virtual is OK, GCC's is too noisy.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif ()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82617.273572.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200626/4dba8188/attachment.bin>
More information about the cfe-commits
mailing list