Commit d023bff9 by Richard Stallman

(non_lvalue): Result must not be null ptr constant.

(omit_one_operand): Use non_lvalue.
(fold, case COMPOUND_EXPR): Use non_lvalue if value is 0.

From-SVN: r3276
parent 441cedbd
...@@ -1580,7 +1580,8 @@ fold_convert (t, arg1) ...@@ -1580,7 +1580,8 @@ fold_convert (t, arg1)
return t; return t;
} }
/* Return an expr equal to X but certainly not valid as an lvalue. */ /* Return an expr equal to X but certainly not valid as an lvalue.
Also make sure it is not valid as an null pointer constant. */
tree tree
non_lvalue (x) non_lvalue (x)
...@@ -1594,7 +1595,15 @@ non_lvalue (x) ...@@ -1594,7 +1595,15 @@ non_lvalue (x)
|| TREE_CODE (x) == REAL_CST || TREE_CODE (x) == REAL_CST
|| TREE_CODE (x) == STRING_CST || TREE_CODE (x) == STRING_CST
|| TREE_CODE (x) == ADDR_EXPR) || TREE_CODE (x) == ADDR_EXPR)
return x; {
if (TREE_CODE (x) == INTEGER_CST && integer_zerop (x))
{
result = build1 (NOP_EXPR, TREE_TYPE (x), x);
TREE_CONSTANT (result) = TREE_CONSTANT (x);
return result;
}
return x;
}
result = build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x); result = build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x);
TREE_CONSTANT (result) = TREE_CONSTANT (x); TREE_CONSTANT (result) = TREE_CONSTANT (x);
...@@ -1990,7 +1999,7 @@ omit_one_operand (type, result, omitted) ...@@ -1990,7 +1999,7 @@ omit_one_operand (type, result, omitted)
if (TREE_SIDE_EFFECTS (omitted)) if (TREE_SIDE_EFFECTS (omitted))
return build (COMPOUND_EXPR, type, omitted, t); return build (COMPOUND_EXPR, type, omitted, t);
return t; return non_lvalue (t);
} }
/* Return a simplified tree node for the truth-negation of ARG. This /* Return a simplified tree node for the truth-negation of ARG. This
...@@ -4339,9 +4348,12 @@ fold (expr) ...@@ -4339,9 +4348,12 @@ fold (expr)
return t; return t;
case COMPOUND_EXPR: case COMPOUND_EXPR:
if (!TREE_SIDE_EFFECTS (arg0)) if (TREE_SIDE_EFFECTS (arg0))
return arg1; return t;
return t; /* Don't let (0, 0) be null pointer constant. */
if (integer_zerop (arg1))
return non_lvalue (arg1);
return arg1;
default: default:
return t; return t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment