re PR middle-end/38771 (error: non-trivial conversion in unary operation)

PR middle-end/38771
	* fold-const.c (fold_unary): For COMPOUND_EXPR and COND_EXPR,
	fold_convert arg0 operands to TREE_TYPE (op0) first.

	* gcc.c-torture/compile/pr38771.c: New test.

From-SVN: r143202
This commit is contained in:
Jakub Jelinek 2009-01-09 14:41:08 +01:00 committed by Jakub Jelinek
parent 76601ca966
commit 4017e262b6
4 changed files with 25 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2009-01-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/38771
* fold-const.c (fold_unary): For COMPOUND_EXPR and COND_EXPR,
fold_convert arg0 operands to TREE_TYPE (op0) first.
2009-01-08 Vladimir Makarov <vmakarov@redhat.com>
* params.def (ira-max-conflict-table-size): Decrease default value

View File

@ -8053,15 +8053,19 @@ fold_unary (enum tree_code code, tree type, tree op0)
{
if (TREE_CODE (arg0) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
fold_build1 (code, type, TREE_OPERAND (arg0, 1)));
fold_build1 (code, type,
fold_convert (TREE_TYPE (op0),
TREE_OPERAND (arg0, 1))));
else if (TREE_CODE (arg0) == COND_EXPR)
{
tree arg01 = TREE_OPERAND (arg0, 1);
tree arg02 = TREE_OPERAND (arg0, 2);
if (! VOID_TYPE_P (TREE_TYPE (arg01)))
arg01 = fold_build1 (code, type, arg01);
arg01 = fold_build1 (code, type,
fold_convert (TREE_TYPE (op0), arg01));
if (! VOID_TYPE_P (TREE_TYPE (arg02)))
arg02 = fold_build1 (code, type, arg02);
arg02 = fold_build1 (code, type,
fold_convert (TREE_TYPE (op0), arg02));
tem = fold_build3 (COND_EXPR, type, TREE_OPERAND (arg0, 0),
arg01, arg02);

View File

@ -1,3 +1,8 @@
2009-01-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/38771
* gcc.c-torture/compile/pr38771.c: New test.
2009-01-08 Nathan Froyd <froydnj@codesourcery.com>
* gcc.dg/pr34856.c: Ignore irrelevant warning.

View File

@ -0,0 +1,7 @@
/* PR middle-end/38771 */
unsigned long long
foo (long long x)
{
return -(unsigned long long) (x ? : x);
}