gimplify.c (shortcut_cond_expr): Re-compute side-effects.

2005-01-26  Stuart Hastings  <stuart@apple.com>

	* gcc/gimplify.c (shortcut_cond_expr): Re-compute side-effects.
	* gcc/testsuite/gcc.c-torture/execute/20050125-1.c: New.

From-SVN: r94300
This commit is contained in:
Stuart Hastings 2005-01-27 01:03:27 +00:00 committed by Stuart Hastings
parent c006df4eec
commit 4356a1bf59
3 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2005-01-26 Stuart Hastings <stuart@apple.com>
* gcc/gimplify.c (shortcut_cond_expr): Re-compute side-effects.
* gcc/testsuite/gcc.c-torture/execute/20050125-1.c: New.
2005-01-26 Richard Henderson <rth@redhat.com>
PR middle-end/18008

View File

@ -1923,6 +1923,7 @@ shortcut_cond_expr (tree expr)
{
TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1);
then_ = shortcut_cond_expr (expr);
then_se = then_ && TREE_SIDE_EFFECTS (then_);
pred = TREE_OPERAND (pred, 0);
expr = build (COND_EXPR, void_type_node, pred, then_, NULL_TREE);
}
@ -1937,6 +1938,7 @@ shortcut_cond_expr (tree expr)
{
TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1);
else_ = shortcut_cond_expr (expr);
else_se = else_ && TREE_SIDE_EFFECTS (else_);
pred = TREE_OPERAND (pred, 0);
expr = build (COND_EXPR, void_type_node, pred, NULL_TREE, else_);
}

View File

@ -0,0 +1,35 @@
/* Verify that the CALL sideeffect isn't optimized away. */
/* Contributed by Greg Parker 25 Jan 2005 <gparker@apple.com> */
#include <stdlib.h>
#include <stdio.h>
struct parse {
char *next;
char *end;
int error;
};
int seterr(struct parse *p, int err)
{
p->error = err;
return 0;
}
void bracket_empty(struct parse *p)
{
if (((p->next < p->end) && (*p->next++) == ']') || seterr(p, 7)) { }
}
int main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
{
struct parse p;
p.next = p.end = (char *)0x12345;
p.error = 0;
bracket_empty(&p);
if (p.error != 7)
abort ();
return 0;
}