Hi guys,

I was looking at merging libiberty&include from gcc to binutils-gdb,
and noticed this one patch that is in binutils-gdb and not in gcc,
since last July.

I think the patch is borderline obvious (it's arguable whether
to define OVERRIDE/FINAL for C), but in interest of re-syncing
the trees, I'm pushing the patch to gcc as is.

Thanks,
Pedro Alves
>From 47ba729a29c6fa2283835d95d2ab5695d8c5d732 Mon Sep 17 00:00:00 2001
From: Nick Clifton <ni...@redhat.com>
Date: Mon, 31 Jul 2017 15:08:32 +0100
Subject: [PATCH] Fix compile time error when using ansidecl.h with an old
 version of GCC.

	Binutils PR 21850
	* ansidecl.h (OVERRIDE): Protect check of __cplusplus value with
	#idef __cplusplus.
---
 include/ChangeLog  |  6 ++++++
 include/ansidecl.h | 30 ++++++++++++++++++------------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index c7ce259..4703588 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -8,6 +8,12 @@
 	* simple-object.h (simple_object_copy_lto_debug_sections): New
 	function.
 
+2017-07-31  Nick Clifton  <ni...@redhat.com>
+
+	Binutils PR 21850
+	* ansidecl.h (OVERRIDE): Protect check of __cplusplus value with
+	#idef __cplusplus.
+
 2017-07-02  Jan Kratochvil  <jan.kratoch...@redhat.com>
 
 	* dwarf2.def (DW_IDX_compile_unit, DW_IDX_type_unit, DW_IDX_die_offset)
diff --git a/include/ansidecl.h b/include/ansidecl.h
index f6e1761..ab3b895 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -334,22 +334,28 @@ So instead we use the macro below and test it against specific values.  */
    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.  final/override were only
-   implemented in 4.7, though.  */
-# if GCC_VERSION < 4007
+#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
+#  define FINAL __final
 # else
-#  define OVERRIDE override
-#  define FINAL final
+   /* No C++11 support; leave the macros empty.  */
+#  define OVERRIDE
+#  define 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: */
+  /* No C++11 support; leave the macros empty.  */
 # define OVERRIDE
 # define FINAL
 #endif
-- 
2.5.5

Reply via email to