From 78de4fe291ea5068342a1d01811e0e9d4b9034e7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 20 Mar 2014 15:49:07 +0000 Subject: [PATCH] Remove configure test for override keyword. Detect its support in the code by testing __cplusplus value and using specific checks for MSVC and Clang as configure detects it as being available when using recent g++ versions in non-C++11 mode, which do support this keyword but warn when it is used without -std={gnu,c}++11 option, which makes actually using it a bad idea in this case. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76174 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- acinclude.m4 | 33 ---------------------------- configure | 56 ----------------------------------------------- configure.in | 3 --- include/wx/defs.h | 18 +++++++-------- setup.h.in | 5 ----- 5 files changed, 9 insertions(+), 106 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 446795784e..bd17ead502 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -255,39 +255,6 @@ AC_DEFUN([WX_CPP_EXPLICIT], fi ]) -dnl --------------------------------------------------------------------------- -dnl WX_CPP_OVERRIDE checks whether the C++ compiler support the override -dnl keyword and defines HAVE_OVERRIDE if this is the case -dnl --------------------------------------------------------------------------- - -AC_DEFUN([WX_CPP_OVERRIDE], -[ - AC_CACHE_CHECK([if C++ compiler supports the override keyword], - wx_cv_override, - [ - AC_LANG_SAVE - AC_LANG_CPLUSPLUS - - AC_TRY_COMPILE( - [ - struct Base { virtual void Foo() = 0; }; - struct Derived : Base { virtual void Foo() override { } }; - ], - [ - return 0; - ], - wx_cv_override=yes, - wx_cv_override=no - ) - - AC_LANG_RESTORE - ]) - - if test "$wx_cv_override" = "yes"; then - AC_DEFINE(HAVE_OVERRIDE) - fi -]) - dnl --------------------------------------------------------------------------- dnl WX_CHECK_FUNCS(FUNCTIONS..., dnl [ACTION-IF-FOUND], diff --git a/configure b/configure index c5c9720b9a..1e86b67b37 100755 --- a/configure +++ b/configure @@ -21173,62 +21173,6 @@ $as_echo "$wx_cv_explicit" >&6; } fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C++ compiler supports the override keyword" >&5 -$as_echo_n "checking if C++ compiler supports the override keyword... " >&6; } -if ${wx_cv_override+:} false; then : - $as_echo_n "(cached) " >&6 -else - - - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - struct Base { virtual void Foo() = 0; }; - struct Derived : Base { virtual void Foo() override { } }; - -int -main () -{ - - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - wx_cv_override=yes -else - wx_cv_override=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_override" >&5 -$as_echo "$wx_cv_override" >&6; } - - if test "$wx_cv_override" = "yes"; then - $as_echo "#define HAVE_OVERRIDE 1" >>confdefs.h - - fi - - if test "x$SUNCXX" = xyes; then CXXFLAGS="-features=tmplife $GNU_SOURCE_FLAG $CXXFLAGS" fi diff --git a/configure.in b/configure.in index c6b73c4c0f..c8d2732531 100644 --- a/configure.in +++ b/configure.in @@ -1793,9 +1793,6 @@ WX_CPP_NEW_HEADERS(, AC_DEFINE(wxUSE_IOSTREAMH)) dnl check whether C++ compiler supports explicit keyword WX_CPP_EXPLICIT -dnl check whether C++ compiler supports override keyword -WX_CPP_OVERRIDE - dnl With Sun CC, temporaries have block scope by default. This flag is needed dnl to get the expression scope behaviour that conforms to the standard. if test "x$SUNCXX" = xyes; then diff --git a/include/wx/defs.h b/include/wx/defs.h index adae065972..8f51b1335f 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -269,21 +269,21 @@ typedef short int WXTYPE; #define wxEXPLICIT #endif /* HAVE_EXPLICIT/!HAVE_EXPLICIT */ -/* check for override keyword support */ +/* check for override keyword support */ #ifndef HAVE_OVERRIDE - #if defined(__VISUALC__) && (__VISUALC__ >= 1400) - /* - VC++ 8.0+ support C++/CLI's override, sealed, and abstract in native - code as a nonstandard extension, and C++/CLI's override fortunately - matches C++11's - */ + #if __cplusplus >= 201103L + /* All C++11 compilers should have it. */ #define HAVE_OVERRIDE - #elif wxCHECK_GCC_VERSION(4, 7) && __cplusplus >= 201103L + #elif wxCHECK_VISUALC_VERSION(8) + /* + VC++ 8.0+ do support override keyword but don't define __cplusplus + as indicating C++11 support, so handle this case specially. + */ #define HAVE_OVERRIDE #elif WX_HAS_CLANG_FEATURE(cxx_override_control) #define HAVE_OVERRIDE #endif -#endif /* !HAVE_OVERRIDE */ +#endif /* !HAVE_OVERRIDE */ #ifdef HAVE_OVERRIDE #define wxOVERRIDE override diff --git a/setup.h.in b/setup.h.in index 02bdf898fb..6b3b5c97b5 100644 --- a/setup.h.in +++ b/setup.h.in @@ -698,11 +698,6 @@ */ #undef HAVE_EXPLICIT -/* - * Define if your compiler supports the override keyword - */ -#undef HAVE_OVERRIDE - /* * Define if your compiler has C99 va_copy */