[binutils-gdb] Fix compile time error when using ansidecl.h with an old version of GCC.

Nick Clifton nickc@sourceware.org
Mon Jul 31 14:09:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c48a4d983400ade9cfba0531905245eb454afe08

commit c48a4d983400ade9cfba0531905245eb454afe08
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Jul 31 15:08:32 2017 +0100

    Fix compile time error when using ansidecl.h with an old version of GCC.
    
    	PR 21850
    	* ansidecl.h (OVERRIDE): Protect check of __cplusplus value with
    	#idef __cplusplus.

Diff:
---
 include/ChangeLog  |  6 ++++++
 include/ansidecl.h | 30 ++++++++++++++++++------------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index da1ce10..443cab0 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-31  Nick Clifton  <nickc@redhat.com>
+
+	PR 21850
+	* ansidecl.h (OVERRIDE): Protect check of __cplusplus value with
+	#idef __cplusplus.
+
 2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
 
 	* opcode/arc.h (SJLI): Add.
diff --git a/include/ansidecl.h b/include/ansidecl.h
index 6c0c837..0a74098 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -328,22 +328,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



More information about the Binutils-cvs mailing list