This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix c/16348
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 4 Jul 2004 10:31:07 -0700
- Subject: fix c/16348
Self explanitory.
r~
PR c/16348
* c-typeck.c (c_finish_loop): Don't clear cond for cond_is_first loops.
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.335
diff -c -p -d -r1.335 c-typeck.c
*** c-typeck.c 4 Jul 2004 08:06:54 -0000 1.335
--- c-typeck.c 4 Jul 2004 17:24:54 -0000
*************** c_finish_loop (location_t start_locus, t
*** 6554,6564 ****
{
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_is_first || cond)
{
tree top = build1 (LABEL_EXPR, void_type_node, NULL_TREE);
--- 6554,6562 ----
{
tree entry = NULL, exit = NULL, t;
/* 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);
Index: testsuite/gcc.c-torture/execute/20040704-1.c
===================================================================
RCS file: testsuite/gcc.c-torture/execute/20040704-1.c
diff -N testsuite/gcc.c-torture/execute/20040704-1.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.c-torture/execute/20040704-1.c 4 Jul 2004 17:24:55 -0000
***************
*** 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;
+ }