diff options
author | Richard Henderson <rth@redhat.com> | 2004-07-04 10:28:56 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2004-07-04 10:28:56 -0700 |
commit | 1ec7a97810257031fe1ae70fe00333a401fad7a6 (patch) | |
tree | cdcbfc29f6b751b2260b151873da7327d57180ab | |
parent | 343a610060e28dffda9123f1678b0e47d3626918 (diff) | |
download | gcc-1ec7a97810257031fe1ae70fe00333a401fad7a6.zip gcc-1ec7a97810257031fe1ae70fe00333a401fad7a6.tar.gz gcc-1ec7a97810257031fe1ae70fe00333a401fad7a6.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20040704-1.c | 14 |
3 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06abd11..86ebbf5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index e5f94915..b704fab 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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); diff --git a/gcc/testsuite/gcc.c-torture/execute/20040704-1.c b/gcc/testsuite/gcc.c-torture/execute/20040704-1.c new file mode 100644 index 0000000..c6b23d0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20040704-1.c @@ -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; +} |