From: Jakub Jelinek Date: Fri, 12 Jun 2015 11:53:34 +0000 (+0200) Subject: re PR middle-end/63608 (error: type mismatch in binary expression) X-Git-Tag: releases/gcc-4.8.5~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45128c988a7f0af1797a8df5b9264f0a893269ee;p=thirdparty%2Fgcc.git re PR middle-end/63608 (error: type mismatch in binary expression) PR middle-end/63608 * gcc.c-torture/compile/pr63608.c: New test. Backported from mainline 2014-05-16 Eric Botcazou * fold-const (fold_unary_loc) : New case. : Pass arg0 instead of op0 to fold_convert_const. From-SVN: r224419 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 755103fa21b8..bea147c5b3db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-06-12 Jakub Jelinek + + PR middle-end/63608 + Backported from mainline + 2014-05-16 Eric Botcazou + + * fold-const (fold_unary_loc) : New case. + : Pass arg0 instead of op0 to fold_convert_const. + 2015-06-11 John David Anglin * config/pa/pa.c (pa_output_global_address): Handle LABEL_REF plus diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 30d50ce696fe..117153175b61 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7865,6 +7865,11 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) return fold_convert_loc (loc, type, op0); return NULL_TREE; + case NON_LVALUE_EXPR: + if (!maybe_lvalue_p (op0)) + return fold_convert_loc (loc, type, op0); + return NULL_TREE; + CASE_CONVERT: case FLOAT_EXPR: case FIX_TRUNC_EXPR: @@ -8128,7 +8133,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) } } - tem = fold_convert_const (code, type, op0); + tem = fold_convert_const (code, type, arg0); return tem ? tem : NULL_TREE; case ADDR_SPACE_CONVERT_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5fa80fd1dd4b..6807d7683405 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-06-12 Jakub Jelinek + + PR middle-end/63608 + * gcc.c-torture/compile/pr63608.c: New test. + 2015-06-11 Richard Biener Backport from mainline diff --git a/gcc/testsuite/gcc.c-torture/compile/pr63608.c b/gcc/testsuite/gcc.c-torture/compile/pr63608.c new file mode 100644 index 000000000000..2d4a09a3516f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr63608.c @@ -0,0 +1,14 @@ +/* PR middle-end/63608 */ + +typedef long T; +typedef unsigned long U; +unsigned long a; + +unsigned long +foo (int b) +{ + T c = 0; + const U d = 2248593032UL; + a = (c = +d) | (~4L & ~b); + return c; +}