On Thu, 2022-05-19 at 08:32 -0400, David Malcolm wrote: > As of GCC 11 onwards we have required a C++11 compiler, such as GCC > 4.8 > or later. On the assumption that any such compiler correctly > implements > "final" and "override", this patch removes the FINAL and OVERRIDE > macros > from ansidecl.h. It adds them back to gcc-plugins.h in case any > plugins > make use of them. > > Followup patches within this kit replace all uses of the macros in > the > tree with the lower-case versions; I've split them up for ease of > review, but would apply them as one combined commit if approved.
I forgot to say: I've successfully bootstrapped & regrtested the combined patches on x86_64-pc-linux-gnu, and (very) lightly tested them on aarch64-linux- gnu. Dave > > gcc/ChangeLog: > * gcc-plugin.h: Add macros OVERRIDE and FINAL. > > include/ChangeLog: > * ansidecl.h: Drop macros OVERRIDE and FINAL. > > Signed-off-by: David Malcolm <dmalc...@redhat.com> > --- > gcc/gcc-plugin.h | 7 +++++++ > include/ansidecl.h | 41 ----------------------------------------- > 2 files changed, 7 insertions(+), 41 deletions(-) > > diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h > index ee9aa865114..f0f3049d0ce 100644 > --- a/gcc/gcc-plugin.h > +++ b/gcc/gcc-plugin.h > @@ -44,4 +44,11 @@ along with GCC; see the file COPYING3. If not see > #include "tree-check.h" > #include "plugin.h" > > +/* Versions of GCC prior to GCC 13 defined these macros in > ansidecl.h > + for C++98 compatibility. Given that we require C++11 from GCC 11 > onwards, > + keep definitions here in case plugins made use of them. */ > + > +#define OVERRIDE override > +#define FINAL final > + > #endif /* GCC_PLUGIN_H */ > diff --git a/include/ansidecl.h b/include/ansidecl.h > index efee5b6904b..119748deb68 100644 > --- a/include/ansidecl.h > +++ b/include/ansidecl.h > @@ -345,47 +345,6 @@ So instead we use the macro below and test it > against specific values. */ > #define CONSTEXPR > #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 defined __cplusplus > -# if __cplusplus >= 201103 > - /* C++11 claims to be available: use it. Final/override were > only > - implemented in 4.7, though. */ > -# if GCC_VERSION < 4007 > -# define OVERRIDE > -# define FINAL > -# else > -# define OVERRIDE override > -# define FINAL final > -# endif > -# elif GCC_VERSION >= 4007 > - /* G++ 4.7 supports __final in C++98. */ > -# define OVERRIDE > -# define FINAL __final > -# else > - /* No C++11 support; leave the macros empty. */ > -# define OVERRIDE > -# define FINAL > -# endif > -#else > - /* No C++11 support; leave the macros empty. */ > -# define OVERRIDE > -# define FINAL > -#endif > - > /* A macro to disable the copy constructor and assignment operator. > When building with C++11 and above, the methods are explicitly > deleted, causing a compile-time error if something tries to copy.