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>
* 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
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))