Please find below a patch moving the FINAL/OVERRIDE macros to include/ansidecl.h, as I was suggesting in the earlier discussion:
On 05/06/2016 07:33 PM, Trevor Saunders wrote: > On Fri, May 06, 2016 at 07:10:33PM +0100, Pedro Alves wrote: >> On 05/06/2016 06:56 PM, Pedro Alves wrote: >> I was going to suggest to put this in include/ansidecl.h, >> so that all C++ libraries / programs in binutils-gdb use the same >> thing, instead of each reinventing the wheel, and I found >> there's already something there: >> >> /* This is used to mark a class or virtual function as final. */ >> #if __cplusplus >= 201103L >> #define GCC_FINAL final >> #elif GCC_VERSION >= 4007 >> #define GCC_FINAL __final >> #else >> #define GCC_FINAL >> #endif >> >> From: >> >> https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00455.html >> >> Apparently the patch that actually uses that was reverted, >> as I can't find any use. > > Yeah, I wanted to use it to work around gdb not dealing well with stuff > in the anon namespace, but somehow that broke aix, and some people > objected and I haven't gotten back to it. > >> I like your names without the GCC_ prefix better though, >> for the same reason of standardizing binutils-gdb + gcc >> on the same symbols. > > I agree, though I'm not really sure when gdb / binutils stuff will > support building as C++11. Meanwhile, GDB master is C++-only nowadays, and we support building with a C++11 compiler, provided there are C++03 fallbacks in place. I'd like to start using FINAL/OVERRIDE, and seems better to me to standardize on the same symbol names across the trees. This patch removes the existing GCC_FINAL macro, since nothing is using it. OK to apply? From: Pedro Alves <pal...@redhat.com> Date: 2016-10-10 19:25:47 +0100 Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h So that GDB and other projects that share the top level can use them. Bootstrapped with all default languages on x86-64 Fedora 23. gcc/ChangeLog: yyyy-mm-dd Pedro Alves <pal...@redhat.com> * coretypes.h (OVERRIDE, FINAL): Delete, moved to include/ansidecl.h. include/ChangeLog: yyyy-mm-dd Pedro Alves <pal...@redhat.com> * ansidecl.h (GCC_FINAL): Delete. (OVERRIDE, FINAL): New, moved from gcc/coretypes.h. --- gcc/coretypes.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index fe1e984..a9c4df9 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -367,31 +367,6 @@ typedef void (*gt_pointer_operator) (void *, void *); typedef unsigned char uchar; #endif -/* C++11 adds the ability to add "override" after an implementation of a - virtual function in a subclass, to: - (A) document that this is an override of a virtual function - (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch - of the type signature). - - Similarly, it allows us to add a "final" to indicate that no subclass - may subsequently override the vfunc. - - Provide OVERRIDE and FINAL as macros, allowing us to get these benefits - when compiling with C++11 support, but without requiring C++11. - - For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables - this by default (actually GNU++14). */ - -#if __cplusplus >= 201103 -/* C++11 claims to be available: use it: */ -#define OVERRIDE override -#define FINAL final -#else -/* No C++11 support; leave the macros empty: */ -#define OVERRIDE -#define FINAL -#endif - /* Most host source files will require the following headers. */ #if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET) #include "machmode.h" diff --git a/include/ansidecl.h b/include/ansidecl.h index 6e4bfc2..ee93421 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -313,13 +313,29 @@ So instead we use the macro below and test it against specific values. */ #define ENUM_BITFIELD(TYPE) unsigned int #endif - /* This is used to mark a class or virtual function as final. */ -#if __cplusplus >= 201103L -#define GCC_FINAL final -#elif GCC_VERSION >= 4007 -#define GCC_FINAL __final +/* C++11 adds the ability to add "override" after an implementation of a + virtual function in a subclass, to: + (A) document that this is an override of a virtual function + (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch + of the type signature). + + Similarly, it allows us to add a "final" to indicate that no subclass + may subsequently override the vfunc. + + Provide OVERRIDE and FINAL as macros, allowing us to get these benefits + when compiling with C++11 support, but without requiring C++11. + + For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables + this by default (actually GNU++14). */ + +#if __cplusplus >= 201103 +/* C++11 claims to be available: use it: */ +#define OVERRIDE override +#define FINAL final #else -#define GCC_FINAL +/* No C++11 support; leave the macros empty: */ +#define OVERRIDE +#define FINAL #endif #ifdef __cplusplus