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
This commit is contained in:
Tom Tromey 2009-05-27 19:53:03 +00:00 committed by Taras Glek
parent c607156f99
commit cea32bca72
2 changed files with 8 additions and 0 deletions

View File

@ -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> 2009-05-27 Ian Lance Taylor <iant@google.com>
* Makefile.in (LINKER, LINKER_FLAGS): Define. * Makefile.in (LINKER, LINKER_FLAGS): Define.

View File

@ -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 change after the fact). Beyond these uses, most other cases of
using this macro should be viewed with extreme caution. */ 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 #if defined(__GNUC__) && GCC_VERSION > 4000
/* GCC 4.0.x has a bug where it may ICE on this expression, /* GCC 4.0.x has a bug where it may ICE on this expression,
so does GCC 3.4.x (PR17436). */ so does GCC 3.4.x (PR17436). */
@ -793,6 +796,7 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
#else #else
#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X)) #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
#endif #endif
#endif
#define CONST_CAST(TYPE,X) CONST_CAST2(TYPE, const TYPE, (X)) #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_TREE(X) CONST_CAST(union tree_node *, (X))
#define CONST_CAST_RTX(X) CONST_CAST(struct rtx_def *, (X)) #define CONST_CAST_RTX(X) CONST_CAST(struct rtx_def *, (X))