mirror of git://gcc.gnu.org/git/gcc.git
re PR c/47150 (ICE in gimplify_expr at gimplify.c)
PR c/47150 * c-convert.c (convert): When converting a complex expression other than COMPLEX_EXPR to a different complex type, ensure c_save_expr is called instead of save_expr, unless in_late_binary_op. * c-typeck.c (convert_for_assignment): Set in_late_binary_op also when converting COMPLEX_TYPE. * gcc.c-torture/compile/pr47150.c: New test. From-SVN: r168537
This commit is contained in:
parent
4192922c74
commit
dfe776dd95
|
@ -1,3 +1,12 @@
|
||||||
|
2011-01-06 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c/47150
|
||||||
|
* c-convert.c (convert): When converting a complex expression
|
||||||
|
other than COMPLEX_EXPR to a different complex type, ensure
|
||||||
|
c_save_expr is called instead of save_expr, unless in_late_binary_op.
|
||||||
|
* c-typeck.c (convert_for_assignment): Set in_late_binary_op also
|
||||||
|
when converting COMPLEX_TYPE.
|
||||||
|
|
||||||
2011-01-06 Ira Rosen <irar@il.ibm.com>
|
2011-01-06 Ira Rosen <irar@il.ibm.com>
|
||||||
|
|
||||||
PR tree-optimization/47139
|
PR tree-optimization/47139
|
||||||
|
|
|
@ -130,6 +130,32 @@ convert (tree type, tree expr)
|
||||||
goto maybe_fold;
|
goto maybe_fold;
|
||||||
|
|
||||||
case COMPLEX_TYPE:
|
case COMPLEX_TYPE:
|
||||||
|
/* If converting from COMPLEX_TYPE to a different COMPLEX_TYPE
|
||||||
|
and e is not COMPLEX_EXPR, convert_to_complex uses save_expr,
|
||||||
|
but for the C FE c_save_expr needs to be called instead. */
|
||||||
|
if (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE)
|
||||||
|
{
|
||||||
|
tree subtype = TREE_TYPE (type);
|
||||||
|
tree elt_type = TREE_TYPE (TREE_TYPE (e));
|
||||||
|
|
||||||
|
if (TYPE_MAIN_VARIANT (elt_type) != TYPE_MAIN_VARIANT (subtype)
|
||||||
|
&& TREE_CODE (e) != COMPLEX_EXPR)
|
||||||
|
{
|
||||||
|
if (in_late_binary_op)
|
||||||
|
e = save_expr (e);
|
||||||
|
else
|
||||||
|
e = c_save_expr (e);
|
||||||
|
ret
|
||||||
|
= fold_build2 (COMPLEX_EXPR, type,
|
||||||
|
convert (subtype,
|
||||||
|
fold_build1 (REALPART_EXPR,
|
||||||
|
elt_type, e)),
|
||||||
|
convert (subtype,
|
||||||
|
fold_build1 (IMAGPART_EXPR,
|
||||||
|
elt_type, e)));
|
||||||
|
goto maybe_fold;
|
||||||
|
}
|
||||||
|
}
|
||||||
ret = convert_to_complex (type, e);
|
ret = convert_to_complex (type, e);
|
||||||
goto maybe_fold;
|
goto maybe_fold;
|
||||||
|
|
||||||
|
|
|
@ -5274,10 +5274,10 @@ convert_for_assignment (location_t location, tree type, tree rhs,
|
||||||
{
|
{
|
||||||
tree ret;
|
tree ret;
|
||||||
bool save = in_late_binary_op;
|
bool save = in_late_binary_op;
|
||||||
if (codel == BOOLEAN_TYPE)
|
if (codel == BOOLEAN_TYPE || codel == COMPLEX_TYPE)
|
||||||
in_late_binary_op = true;
|
in_late_binary_op = true;
|
||||||
ret = convert_and_check (type, orig_rhs);
|
ret = convert_and_check (type, orig_rhs);
|
||||||
if (codel == BOOLEAN_TYPE)
|
if (codel == BOOLEAN_TYPE || codel == COMPLEX_TYPE)
|
||||||
in_late_binary_op = save;
|
in_late_binary_op = save;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-01-06 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c/47150
|
||||||
|
* gcc.c-torture/compile/pr47150.c: New test.
|
||||||
|
|
||||||
2011-01-06 Ira Rosen <irar@il.ibm.com>
|
2011-01-06 Ira Rosen <irar@il.ibm.com>
|
||||||
|
|
||||||
PR tree-optimization/47139
|
PR tree-optimization/47139
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* PR c/47150 */
|
||||||
|
|
||||||
|
float _Complex foo (float, float);
|
||||||
|
|
||||||
|
void
|
||||||
|
bar ()
|
||||||
|
{
|
||||||
|
float w = 2;
|
||||||
|
float _Complex b;
|
||||||
|
b = 0.5 * (foo (0, w) + foo (1, w) / w);
|
||||||
|
}
|
Loading…
Reference in New Issue