]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - gcc/patches/gcc49-pr56493.patch0
87603db1ab878e3fcb70180c4c3f1055db8d5fe6
[people/arne_f/ipfire-3.x.git] / gcc / patches / gcc49-pr56493.patch0
1 2013-06-17 Jakub Jelinek <jakub@redhat.com>
2
3 PR c++/56493
4 * convert.c (convert_to_real, convert_to_expr, convert_to_complex):
5 Handle COMPOUND_EXPR.
6
7 * c-c++-common/pr56493.c: New test.
8
9 --- gcc/convert.c.jj 2013-05-13 09:44:53.000000000 +0200
10 +++ gcc/convert.c 2013-06-16 12:16:13.754108523 +0200
11 @@ -95,6 +95,15 @@ convert_to_real (tree type, tree expr)
12 enum built_in_function fcode = builtin_mathfn_code (expr);
13 tree itype = TREE_TYPE (expr);
14
15 + if (TREE_CODE (expr) == COMPOUND_EXPR)
16 + {
17 + tree t = convert_to_real (type, TREE_OPERAND (expr, 1));
18 + if (t == TREE_OPERAND (expr, 1))
19 + return expr;
20 + return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
21 + TREE_OPERAND (expr, 0), t);
22 + }
23 +
24 /* Disable until we figure out how to decide whether the functions are
25 present in runtime. */
26 /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */
27 @@ -366,6 +375,15 @@ convert_to_integer (tree type, tree expr
28 return error_mark_node;
29 }
30
31 + if (ex_form == COMPOUND_EXPR)
32 + {
33 + tree t = convert_to_integer (type, TREE_OPERAND (expr, 1));
34 + if (t == TREE_OPERAND (expr, 1))
35 + return expr;
36 + return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR, TREE_TYPE (t),
37 + TREE_OPERAND (expr, 0), t);
38 + }
39 +
40 /* Convert e.g. (long)round(d) -> lround(d). */
41 /* If we're converting to char, we may encounter differing behavior
42 between converting from double->char vs double->long->char.
43 @@ -854,6 +872,14 @@ convert_to_complex (tree type, tree expr
44
45 if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
46 return expr;
47 + else if (TREE_CODE (expr) == COMPOUND_EXPR)
48 + {
49 + tree t = convert_to_complex (type, TREE_OPERAND (expr, 1));
50 + if (t == TREE_OPERAND (expr, 1))
51 + return expr;
52 + return build2_loc (EXPR_LOCATION (expr), COMPOUND_EXPR,
53 + TREE_TYPE (t), TREE_OPERAND (expr, 0), t);
54 + }
55 else if (TREE_CODE (expr) == COMPLEX_EXPR)
56 return fold_build2 (COMPLEX_EXPR, type,
57 convert (subtype, TREE_OPERAND (expr, 0)),
58 --- gcc/testsuite/c-c++-common/pr56493.c.jj 2013-06-17 10:24:36.891659600 +0200
59 +++ gcc/testsuite/c-c++-common/pr56493.c 2013-06-17 10:24:33.164720149 +0200
60 @@ -0,0 +1,16 @@
61 +/* PR c++/56493 */
62 +/* { dg-do compile } */
63 +/* { dg-options "-O2 -fdump-tree-gimple" } */
64 +
65 +unsigned long long bar (void);
66 +int x;
67 +
68 +void
69 +foo (void)
70 +{
71 + x += bar ();
72 +}
73 +
74 +/* Verify we narrow the addition from unsigned long long to unsigned int type. */
75 +/* { 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 } } } } */
76 +/* { dg-final { cleanup-tree-dump "gimple" } } */