gcc -Woverloaded-virtual
Allen Winter
winter at kde.org
Fri Nov 16 14:43:46 GMT 2007
Howdy,
Vir and I think we should add the gcc option -Woverloaded-virtual to the CXXFLAGS.
Can we do this?
From the gcc man page:
-Woverloaded-virtual (C++ only)
Warn when a function declaration hides virtual functions from a base class.
For example, in:
struct A {
virtual void f();
};
struct B: public A {
void f(int);
};
the "A" class version of "f" is hidden in "B", and code like:
B* b;
b->f();
will fail to compile.
Here's a patch:
===================================================================
--- FindKDE4Internal.cmake (revision 737556)
+++ FindKDE4Internal.cmake (working copy)
@@ -858,6 +858,11 @@ if (CMAKE_COMPILER_IS_GNUCXX)
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
endif (__KDE_HAVE_NO_THREADSAFE_STATICS)
+ check_cxx_compiler_flag(-Woverloaded-virtual __KDE_HAVE_W_OVERLOADED_VIRTUAL)
+ if(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+ endif(__KDE_HAVE_W_OVERLOADED_VIRTUAL)
+
# visibility support
check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
set( __KDE_HAVE_GCC_VISIBILITY ${__KDE_HAVE_GCC_VISIBILITY} CACHE BOOL "GCC support for h
idden visibility")
More information about the kde-core-devel
mailing list