Blame SOURCES/gcc48-pr80362.patch

8178f7
2017-09-18  Richard Biener  <rguenther@suse.de>
8178f7
8178f7
	Backport from mainline
8178f7
	2017-04-10  Richard Biener  <rguenther@suse.de>
8178f7
8178f7
	PR middle-end/80362
8178f7
	* fold-const.c (fold_binary_loc): Look at unstripped ops when
8178f7
	looking for NEGATE_EXPR in -A / -B to A / B folding.
8178f7
8178f7
	* gcc.dg/torture/pr80362.c: New testcase.
8178f7
8178f7
--- gcc/fold-const.c
8178f7
+++ gcc/fold-const.c
8178f7
@@ -11940,8 +11942,8 @@ fold_binary_loc (location_t loc,
8178f7
       /* Convert -A / -B to A / B when the type is signed and overflow is
8178f7
 	 undefined.  */
8178f7
       if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
8178f7
-	  && TREE_CODE (arg0) == NEGATE_EXPR
8178f7
-	  && negate_expr_p (arg1))
8178f7
+	  && TREE_CODE (op0) == NEGATE_EXPR
8178f7
+	  && negate_expr_p (op1))
8178f7
 	{
8178f7
 	  if (INTEGRAL_TYPE_P (type))
8178f7
 	    fold_overflow_warning (("assuming signed overflow does not occur "
8178f7
--- /dev/null
8178f7
+++ gcc/testsuite/gcc.dg/torture/pr80362.c
8178f7
@@ -0,0 +1,11 @@
8178f7
+/* { dg-do run } */
8178f7
+/* { dg-additional-options "-fstrict-overflow" } */
8178f7
+
8178f7
+int main()
8178f7
+{
8178f7
+  signed char var_0, var_1 = -128;
8178f7
+  var_0 = (signed char)(-var_1) / 3;
8178f7
+  if (var_0 > 0)
8178f7
+    __builtin_abort();
8178f7
+  return 0;
8178f7
+}