This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: import changes from gcc-in-cxx branch
- From: Brad Hards <bradh at frogmouth dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 16 May 2009 18:26:46 +1000
- Subject: Re: import changes from gcc-in-cxx branch
- References: <200905152143.37597.bradh@frogmouth.net>
On Friday 15 May 2009 09:43:36 pm Brad Hards wrote:
> Attached is a patch that improves C++ compatibility, to allow
> dehydra/treehydra to build against trunk.
Ian committed a patch (see -Wc++-compat warn about typedef/tag conflict mail)
that covers most of this. Here is an updated patch.
> I didn't actually write it - I just hand-ported bits over from the
> gcc-in-cxx branch.
>
> 2009-05-15 Brad Hards <bradh@kde.org>
>
> * system.h: Add C++ compatible CONST_CAST2 definition
--- system.h (revision 147608)
+++ system.h (working copy)
@@ -785,7 +785,9 @@
context. (This can be somewhat dangerous as these assumptions can
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 +795,7 @@
#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))
Can this please be applied?
Brad