diff mbox

[1/2] add GCC_FINAL to ansidecl.h

Message ID 1439208314-7390-1-git-send-email-tbsaunde+gcc@tbsaunde.org
State New
Headers show

Commit Message

tbsaunde+gcc@tbsaunde.org Aug. 10, 2015, 12:05 p.m. UTC
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

This allows classes and virtual functions to be marked as final if the compiler
supports C++11, or is gcc 4.7 or later.

bootstrapped + regtested on x86_64-linux-gnu, ok?

Trev

include/ChangeLog:

2015-08-10  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* ansidecl.h (GCC_FINAL): New macro.
---
 include/ansidecl.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jeff Law Aug. 11, 2015, 7:21 p.m. UTC | #1
On 08/10/2015 06:05 AM, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> Hi,
>
> This allows classes and virtual functions to be marked as final if the compiler
> supports C++11, or is gcc 4.7 or later.
>
> bootstrapped + regtested on x86_64-linux-gnu, ok?
>
> Trev
>
> include/ChangeLog:
>
> 2015-08-10  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
> 	* ansidecl.h (GCC_FINAL): New macro.
OK.
jeff
diff mbox

Patch

diff --git a/include/ansidecl.h b/include/ansidecl.h
index 224627d..6e4bfc2 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -313,6 +313,15 @@  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
+#else
+#define GCC_FINAL
+#endif
+
 #ifdef __cplusplus
 }
 #endif