[gcc-in-cxx] Patch: CONST_CAST2 -vs- C++
Tom Tromey
tromey@redhat.com
Sun Jun 22 20:13:00 GMT 2008
This patch defines CONST_CAST2 differently for C++.
This fixes a few build errors on the branch.
Ok? (I wasn't sure whether, under the branch rules, I could approve
my own C++-ification patches.)
Tom
ChangeLog.cxx:
2008-06-21 Tom Tromey <tromey@redhat.com>
* system.h (CONST_CAST2): Define for C++.
Index: system.h
===================================================================
--- system.h (revision 137020)
+++ system.h (working copy)
@@ -786,12 +786,16 @@
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. */
#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
#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))
More information about the Gcc-patches
mailing list