Blame SOURCES/gcc48-pr56493.patch

543165
2013-06-17  Jakub Jelinek  <jakub@redhat.com>
543165
543165
	PR c++/56493
543165
	* convert.c (convert_to_real, convert_to_expr, convert_to_complex):
543165
	Handle COMPOUND_EXPR.
543165
543165
	* c-c++-common/pr56493.c: New test.
543165
543165
--- gcc/convert.c.jj	2013-05-13 09:44:53.000000000 +0200
543165
+++ gcc/convert.c	2013-06-16 12:16:13.754108523 +0200
543165
@@ -95,6 +95,15 @@ convert_to_real (tree type, tree expr)
543165
   enum built_in_function fcode = builtin_mathfn_code (expr);
543165
   tree itype = TREE_TYPE (expr);
543165
 
543165
+  if (TREE_CODE (expr) == COMPOUND_EXPR)
543165
+    {
543165
+      tree t = convert_to_real (type, TREE_OPERAND (expr, 1));
543165
+      if (t == TREE_OPERAND (expr, 1))
543165
+	return expr;
543165
+      return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
543165
+			 TREE_OPERAND (expr, 0), t);
543165
+    }    
543165
+
543165
   /* Disable until we figure out how to decide whether the functions are
543165
      present in runtime.  */
543165
   /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
543165
@@ -366,6 +375,15 @@ convert_to_integer (tree type, tree expr
543165
       return error_mark_node;
543165
     }
543165
 
543165
+  if (ex_form == COMPOUND_EXPR)
543165
+    {
543165
+      tree t = convert_to_integer (type, TREE_OPERAND (expr, 1));
543165
+      if (t == TREE_OPERAND (expr, 1))
543165
+	return expr;
543165
+      return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
543165
+			 TREE_OPERAND (expr, 0), t);
543165
+    }    
543165
+
543165
   /* Convert e.g. (long)round(d) -> lround(d).  */
543165
   /* If we're converting to char, we may encounter differing behavior
543165
      between converting from double->char vs double->long->char.
543165
@@ -854,6 +872,14 @@ convert_to_complex (tree type, tree expr
543165
 
543165
 	if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
543165
 	  return expr;
543165
+	else if (TREE_CODE (expr) == COMPOUND_EXPR)
543165
+	  {
543165
+	    tree t = convert_to_complex (type, TREE_OPERAND (expr, 1));
543165
+	    if (t == TREE_OPERAND (expr, 1))
543165
+	      return expr;
543165
+	    return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR,
543165
+			       TREE_TYPE (t), TREE_OPERAND (expr, 0), t);
543165
+	  }    
543165
 	else if (TREE_CODE (expr) == COMPLEX_EXPR)
543165
 	  return fold_build2 (COMPLEX_EXPR, type,
543165
 			      convert (subtype, TREE_OPERAND (expr, 0)),
543165
--- gcc/testsuite/c-c++-common/pr56493.c.jj	2013-06-17 10:24:36.891659600 +0200
543165
+++ gcc/testsuite/c-c++-common/pr56493.c	2013-06-17 10:24:33.164720149 +0200
543165
@@ -0,0 +1,16 @@
543165
+/* PR c++/56493 */
543165
+/* { dg-do compile } */
543165
+/* { dg-options "-O2 -fdump-tree-gimple" } */
543165
+
543165
+unsigned long long bar (void);
543165
+int x;
543165
+
543165
+void
543165
+foo (void)
543165
+{
543165
+  x += bar ();
543165
+}
543165
+
543165
+/* Verify we narrow the addition from unsigned long long to unsigned int type.  */
543165
+/* { dg-final { scan-tree-dump "  (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.*  (\[a-zA-Z._0-9]*) = \\(unsigned int\\) \[^;\n\r]*;.* = \\1 \\+ \\2;" "gimple" { target { ilp32 || lp64 } } } } */
543165
+/* { dg-final { cleanup-tree-dump "gimple" } } */