aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-05-06 17:02:01 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-05-06 17:02:01 +0000
commita89f917b6714d53e3fb4ba6ae67f71e75d20b907 (patch)
treeb587b515a1ec11b0bafdc810722b776451253aae
parent0e19f3b3348baf1a0be7ce81df2613c3a5b3e934 (diff)
downloadgcc-a89f917b6714d53e3fb4ba6ae67f71e75d20b907.zip
gcc-a89f917b6714d53e3fb4ba6ae67f71e75d20b907.tar.gz
gcc-a89f917b6714d53e3fb4ba6ae67f71e75d20b907.tar.bz2
Add OVERRIDE and FINAL macros to coretypes.h
gcc/ChangeLog: * coretypes.h (OVERRIDE): New macro. (FINAL): New macro. From-SVN: r235981
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/coretypes.h25
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0870dfb..9b03ac3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-06 David Malcolm <dmalcolm@redhat.com>
+
+ * coretypes.h (OVERRIDE): New macro.
+ (FINAL): New macro.
+
2016-05-06 Eric Botcazou <ebotcazou@adacore.com>
* tree-ssa-coalesce.c (gimple_can_coalesce_p): In the optimized case,
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2932d73..b3a91a6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -361,6 +361,31 @@ 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"