]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/63608 (error: type mismatch in binary expression)
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Jun 2015 11:52:42 +0000 (13:52 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Jun 2015 11:52:42 +0000 (13:52 +0200)
PR middle-end/63608
* gcc.c-torture/compile/pr63608.c: New test.

Backported from mainline
2014-05-16  Eric Botcazou  <ebotcazou@adacore.com>

* fold-const (fold_unary_loc) <NON_LVALUE_EXPR>: New case.
<CASE_CONVERT>: Pass arg0 instead of op0 to fold_convert_const.

From-SVN: r224418

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr63608.c [new file with mode: 0644]

index ca0bc6aad2eed80d84068b77b24f9ade92991796..971906297dcbb4d087f8f3ece2cbf54373ac4a5d 100644 (file)
@@ -1,3 +1,12 @@
+2015-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/63608
+       Backported from mainline
+       2014-05-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * fold-const (fold_unary_loc) <NON_LVALUE_EXPR>: New case.
+       <CASE_CONVERT>: Pass arg0 instead of op0 to fold_convert_const.
+
 2015-06-11  John David Anglin  <danglin@gcc.gnu.org>
 
        * config/pa/pa.c (pa_output_global_address): Handle LABEL_REF plus
index 71e1e0a5785a6b2403b04c4491ba111129977a20..82b68bf3a9d623aac907014869c56e10bbcc03c1 100644 (file)
@@ -7941,6 +7941,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:
@@ -8204,7 +8209,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:
index 649c6ff7c749c8070d964cc69a57a5dc383521ac..904d256f5214bdd5801702e6c1f6742d4585f506 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/63608
+       * gcc.c-torture/compile/pr63608.c: New test.
+
 2015-06-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/66470
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr63608.c b/gcc/testsuite/gcc.c-torture/compile/pr63608.c
new file mode 100644 (file)
index 0000000..2d4a09a
--- /dev/null
@@ -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;
+}