diff mbox

Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h

Message ID 014f88ec-909b-db46-1213-e9dbb8f14ee4@redhat.com
State New
Headers show

Commit Message

Pedro Alves Oct. 12, 2016, 2:09 p.m. UTC
On 10/12/2016 03:01 PM, Bernd Schmidt wrote:
> On 10/10/2016 09:32 PM, Pedro Alves wrote:
>> From: Pedro Alves <palves@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.
> 
> Seems reasonable. OK unless someone objects by the end of the week.

Thanks.  Here's a follow up patch that I was just testing.

Need this if building with "g++ -std=gnu++11", with gcc < 4.7.

From: Pedro Alves <palves@redhat.com>
Date: 2016-10-12 01:49:53 +0100

FINAL/OVERRIDE: Define to empty on g++ < 4.7

final/override were only implemented in 4.7.

include/ChangeLog
2016-10-12  Pedro Alves  <palves@redhat.com>

	* ansidecl.h [__cplusplus >= 201103 && GCC_VERSION > 4007] (FINAL,
	OVERRIDE): Define as empty.
	[__cplusplus < 201103 && GCC_VERSION > 4007] (FINAL): Define as
	__final.
	[__cplusplus < 201103 && GCC_VERSION > 4007] (OVERRIDE): Define as
	empty.
---

 include/ansidecl.h |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Bernd Schmidt Oct. 12, 2016, 2:13 p.m. UTC | #1
On 10/12/2016 04:09 PM, Pedro Alves wrote:
>
> Thanks.  Here's a follow up patch that I was just testing.
>
> Need this if building with "g++ -std=gnu++11", with gcc < 4.7.

Lovely. That's ok too if the other one goes in.


Bernd
Pedro Alves Oct. 14, 2016, 3:27 p.m. UTC | #2
On 10/12/2016 03:13 PM, Bernd Schmidt wrote:
> On 10/12/2016 04:09 PM, Pedro Alves wrote:
>>
>> Thanks.  Here's a follow up patch that I was just testing.
>>
>> Need this if building with "g++ -std=gnu++11", with gcc < 4.7.
> 
> Lovely. That's ok too if the other one goes in.

FYI, I pushed these in now.  I also bootstrapped with the
jit included in the selected languages, and hacked the
jit code a bit to trigger the problems OVERRIDE intends to
catch, just to make sure it still works.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/include/ansidecl.h b/include/ansidecl.h
index ee93421..08aeb1e 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -329,13 +329,23 @@  So instead we use the macro below and test it against specific values.  */
    this by default (actually GNU++14).  */
 
 #if __cplusplus >= 201103
-/* C++11 claims to be available: use it: */
-#define OVERRIDE override
-#define FINAL final
+/* 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
+# define OVERRIDE
+# define FINAL
 #endif
 
 #ifdef __cplusplus