re PR c/16348 (Loop gets executed when it shouldnt)

PR c/16348
        * c-typeck.c (c_finish_loop): Don't clear cond for cond_is_first loops.

From-SVN: r84089
This commit is contained in:
Richard Henderson 2004-07-04 10:28:56 -07:00 committed by Richard Henderson
parent 343a610060
commit 1ec7a97810
3 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2004-07-04 Richard Henderson <rth@redhat.com>
PR c/16348
* c-typeck.c (c_finish_loop): Don't clear cond for cond_is_first loops.
2004-07-04 Mark Mitchell <mark@codesourcery.com>
* configure.ac (ranlib_flags): New variable.

View File

@ -6554,11 +6554,9 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
{
tree entry = NULL, exit = NULL, t;
/* Force zeros to NULL so that we don't test them. */
if (cond && integer_zerop (cond))
cond = NULL;
/* Detect do { ... } while (0) and don't generate loop construct. */
if (cond && !cond_is_first && integer_zerop (cond))
cond = NULL;
if (cond_is_first || cond)
{
tree top = build1 (LABEL_EXPR, void_type_node, NULL_TREE);

View File

@ -0,0 +1,14 @@
/* PR 16348: Make sure that condition-first false loops DTRT. */
extern void abort ();
int main()
{
for (; 0 ;)
{
abort ();
label:
return 0;
}
goto label;
}