From: Francesco Chemolli Date: Wed, 26 Aug 2015 14:20:57 +0000 (+0200) Subject: Implement and use detection of compiler support for c++11 override keyword X-Git-Tag: SQUID_4_0_1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e72a7032cd42f75730da6b71fec9afa62f40e3c5;p=thirdparty%2Fsquid.git Implement and use detection of compiler support for c++11 override keyword --- diff --git a/acinclude/ax_cxx_0x_types.m4 b/acinclude/ax_cxx_0x_types.m4 index 270d378e2f..f58b119274 100644 --- a/acinclude/ax_cxx_0x_types.m4 +++ b/acinclude/ax_cxx_0x_types.m4 @@ -80,3 +80,26 @@ AC_DEFUN([AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS],[ AC_LANG_POP ]) + +AC_DEFUN([AX_CXX11_SUPPORTS_OVERRIDE_KEYWORD],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH([C++]) + AC_CACHE_CHECK([whether the c++11 compiler supports the override keyword], + [squid_cv_cxx11_supports_override],[ + AC_TRY_COMPILE([],[ +class Base { + public: + virtual void method() {} +}; +class Derived : public Base { + public: + virtual void method() override {} +}; +Derived d; d.method(); + ],[squid_cv_cxx11_supports_override=yes],[squid_cv_cxx11_supports_override=no]) + ]) + AC_LANG_POP + SQUID_DEFINE_BOOL([HAVE_CXX11_OVERRIDE_KEYWORD],[$squid_cv_cxx11_supports_override], + [Define if the c++11 compiler supports c++ override keyword for class methods]) +]) + diff --git a/compat/types.h b/compat/types.h index c04777d9a4..f0418d7592 100644 --- a/compat/types.h +++ b/compat/types.h @@ -181,5 +181,12 @@ typedef long mtyp_t; #define xuniform_real_distribution std::tr1::uniform_real #endif +#if HAVE_CXX11_OVERRIDE_KEYWORD +///use in place of c++11 "override" keyword, will expand to keyword if compiler supports +#define OVERRIDE override +#else +#define OVERRIDE +#endif + #endif /* SQUID_TYPES_H */ diff --git a/configure.ac b/configure.ac index d0c55fed2b..323afbdd4e 100644 --- a/configure.ac +++ b/configure.ac @@ -2939,6 +2939,7 @@ dnl Some C++11 types we try to use AX_CXX_TYPE_NULLPTR AX_CXX_TYPE_UNIQUE_PTR AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS +AX_CXX11_SUPPORTS_OVERRIDE_KEYWORD dnl On Solaris 9 x86, gcc may includes a "fixed" set of old system include files dnl that is incompatible with the updated Solaris header files. diff --git a/src/acl/Tree.h b/src/acl/Tree.h index c13e7afdfb..0bddc9d3c9 100644 --- a/src/acl/Tree.h +++ b/src/acl/Tree.h @@ -41,7 +41,7 @@ public: protected: /// Acl::OrNode API - virtual bool bannedAction(ACLChecklist *, Nodes::const_iterator) const override; + virtual bool bannedAction(ACLChecklist *, Nodes::const_iterator) const OVERRIDE; allow_t actionAt(const Nodes::size_type pos) const; /// if not empty, contains actions corresponding to InnerNode::nodes