On Fri, 2016-05-06 at 18:20 +0200, Jakub Jelinek wrote: > On Fri, May 06, 2016 at 12:40:45PM -0400, David Malcolm wrote: > > 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. > > > > We use virtual functions in a few places (e.g. in the jit), so it > > would > > be good to get this extra checking. > > > > This patch adds OVERRIDE and FINAL as macros to coretypes.h > > allowing us to get this extra checking when compiling with a > > compiler > > that implements C++11 or later (e.g. gcc 6 by default), > > but without requiring C++11. > > Don't we also want CONSTEXPR similarly defined to constexpr for C++11 > and > above and nothing otherwise?
Perhaps, but CONSTEXPR seems to be more awkward than OVERRIDE and FINAL. The meanings of "final" and "override" are consistent between C++11 and C++14, but C++14 allows more things to be marked as "constexpr" than C++11. Hence having a single "CONSTEXPR" macro might not be sufficient. Perhaps there'd be CONSTEXPR_11 and CONSTEXPR_14 macros for things that are constexpr in C++11 onwards and constexpr in C++14 onwards, respectively? (seems ugly to me). Are the OVERRIDE and FINAL macros OK for trunk? Thanks Dave