From cea32bca722edb23b8225c79be664232c3b756b5 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Wed, 27 May 2009 19:53:03 +0000
Subject: [PATCH] system.h (CONST_CAST2): Use C++ const_cast when compiled as
 C++

gcc/ChangeLog
	* system.h (CONST_CAST2): Use C++ const_cast when compiled as C++

From-SVN: r147928
---
 gcc/ChangeLog | 4 ++++
 gcc/system.h  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b32b86bb67c0..306b3f844d87 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2009-05-27  Tom Tromey  <tromey@redhat.com>
+
+	* system.h (CONST_CAST2): Use C++ const_cast when compiled as C++
+
 2009-05-27  Ian Lance Taylor  <iant@google.com>
 
 	* Makefile.in (LINKER, LINKER_FLAGS): Define.
diff --git a/gcc/system.h b/gcc/system.h
index 223a9dd01b44..2a111ee8e84c 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -786,6 +786,9 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
    change after the fact).  Beyond these uses, most other cases of
    using this macro should be viewed with extreme caution.  */
 
+#ifdef __cplusplus
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))
+#else
 #if defined(__GNUC__) && GCC_VERSION > 4000
 /* GCC 4.0.x has a bug where it may ICE on this expression,
    so does GCC 3.4.x (PR17436).  */
@@ -793,6 +796,7 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 #else
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
 #endif
+#endif
 #define CONST_CAST(TYPE,X) CONST_CAST2(TYPE, const TYPE, (X))
 #define CONST_CAST_TREE(X) CONST_CAST(union tree_node *, (X))
 #define CONST_CAST_RTX(X) CONST_CAST(struct rtx_def *, (X))
-- 
GitLab