Geoffrey Keating <gkeating@apple.com> writes:
2003-04-29 Geoffrey Keating <geoffk@apple.com>
* c-semantics.c (expand_unreachable_stmt): Return a tree.
(expand_stmt): Update for change to expand_unreachable_stmt.
(expand_unreachable_if_stmt): Likewise.
This patch caused an ICE on the test case below. It missed some
callers of expand_unreachable_stmt, so the else clause was no
longer being expanded.
Patch bootstrapped & regression tested on i686-pc-linux-gnu.
OK to install?
* c-semantics.c (genrtl_if_stmt): Pass the return value of
expand_unreachable_stmt to expand_stmt.
(genrtl_switch_stmt): Likewise.
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.56
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.56 c-semantics.c
*** c-semantics.c 29 Apr 2003 20:39:12 -0000 1.56
--- c-semantics.c 2 May 2003 13:18:39 -0000
*************** genrtl_if_stmt (t)
*** 416,434 ****
expand_start_cond (cond, 0);
if (THEN_CLAUSE (t))
{
! if (cond && integer_zerop (cond))
! expand_unreachable_stmt (THEN_CLAUSE (t), warn_notreached);
! else
! expand_stmt (THEN_CLAUSE (t));
}
if (ELSE_CLAUSE (t))
{
expand_start_else ();
! if (cond && integer_nonzerop (cond))
! expand_unreachable_stmt (ELSE_CLAUSE (t), warn_notreached);
! else
! expand_stmt (ELSE_CLAUSE (t));
}
expand_end_cond ();
}
--- 416,434 ----
expand_start_cond (cond, 0);
if (THEN_CLAUSE (t))
{
! expand_stmt
! (cond && integer_zerop (cond)
! ? expand_unreachable_stmt (THEN_CLAUSE (t), warn_notreached)
! : THEN_CLAUSE (t));
}
if (ELSE_CLAUSE (t))
{
expand_start_else ();
! expand_stmt
! (cond && integer_nonzerop (cond)
! ? expand_unreachable_stmt (ELSE_CLAUSE (t), warn_notreached)
! : ELSE_CLAUSE (t));
}
expand_end_cond ();
}
*************** genrtl_switch_stmt (t)
*** 687,693 ****
emit_line_note (input_filename, lineno);
expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
! expand_unreachable_stmt (SWITCH_BODY (t), warn_notreached);
expand_end_case_type (cond, SWITCH_TYPE (t));
}
--- 687,693 ----
emit_line_note (input_filename, lineno);
expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
! expand_stmt (expand_unreachable_stmt (SWITCH_BODY (t),
warn_notreached));
expand_end_case_type (cond, SWITCH_TYPE (t));
}
*** /dev/null Thu Apr 11 15:25:15 2002
--- testsuite/gcc.c-torture/compile/20030502.c Fri May 2 14:16:32 2003
***************
*** 0 ****
--- 1,12 ----
+ void foo ()
+ {
+ if (1)
+ goto foo;
+ else
+ for (;;)
+ {
+ foo:
+ bar ();
+ return;
+ }
+ }