My changes to get_narrower to support COMPOUND_EXPRs apparently
used a wrong type for the COMPOUND_EXPRs, while e.g. the rhs
type was unsigned short, the COMPOUND_EXPR got int type as that was the
original type of op. The type of COMPOUND_EXPR should be always the type
of the rhs.
2020-08-11 Jakub Jelinek <jakub@redhat.com>
PR c/96549
* tree.c (get_narrower): Use TREE_TYPE (ret) instead of
TREE_TYPE (win) for COMPOUND_EXPRs.
* gcc.c-torture/execute/pr96549.c: New test.
--- /dev/null
+/* PR c/96549 */
+
+long c = -1L;
+long b = 0L;
+
+int
+main ()
+{
+ if (3L > (short) ((c ^= (b = 1L)) * 3L))
+ return 0;
+ __builtin_abort ();
+}
v.safe_push (op);
FOR_EACH_VEC_ELT_REVERSE (v, i, op)
ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
- TREE_TYPE (win), TREE_OPERAND (op, 0),
+ TREE_TYPE (ret), TREE_OPERAND (op, 0),
ret);
return ret;
}