From: jason Date: Tue, 17 Nov 2015 21:49:23 +0000 (+0000) Subject: PR bootstrap/68346 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c77e6e51f3def12b1ad416dac4b907f2245b047;p=thirdparty%2Fgcc.git PR bootstrap/68346 * typeck.c (build_static_cast_1): Force a NOP when converting to the same type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230508 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b46362dfe7d6..267bd192335e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-11-17 Jason Merrill + PR bootstrap/68346 + * typeck.c (build_static_cast_1): Force a NOP when converting to + the same type. + * cp-tree.h (LITERAL_ZERO_P): Remove. * parser.c (cp_parser_postfix_expression, literal_zeros) (cp_parser_parenthesized_expression_list): Don't mess with it. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b7395cf072a4..5f7d4bb994ad 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6668,7 +6668,13 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, If T is a reference type, the result is an lvalue; otherwise, the result is an rvalue. */ if (TREE_CODE (type) != REFERENCE_TYPE) - result = rvalue (result); + { + result = rvalue (result); + + if (result == expr && SCALAR_TYPE_P (type)) + /* Leave some record of the cast. */ + result = build_nop (type, expr); + } return result; }