aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2000-11-01 02:28:32 -0800
committerRichard Henderson <rth@gcc.gnu.org>2000-11-01 02:28:32 -0800
commitf0de0c5d1735d0e47fcd9eed2c55c7447be3db7c (patch)
treed2b3df2dede1479fa71732f0f3a0c2144a986dfb
parentfaafaee632fa113c37c2d97cc8ebcc4ce4bc6e8c (diff)
downloadgcc-f0de0c5d1735d0e47fcd9eed2c55c7447be3db7c.zip
gcc-f0de0c5d1735d0e47fcd9eed2c55c7447be3db7c.tar.gz
gcc-f0de0c5d1735d0e47fcd9eed2c55c7447be3db7c.tar.bz2
stmt.c (expand_start_null_loop): New.
* stmt.c (expand_start_null_loop): New. (expand_end_null_loop): New. * c-semantics.c (genrtl_do_stmt): Use them. * tree.h: Declare them. From-SVN: r37186
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-semantics.c6
-rw-r--r--gcc/stmt.c37
-rw-r--r--gcc/tree.h2
4 files changed, 51 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a29f68c..c8b0dff 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2000-11-01 Richard Henderson <rth@redhat.com>
+ * stmt.c (expand_start_null_loop): New.
+ (expand_end_null_loop): New.
+ * c-semantics.c (genrtl_do_stmt): Use them.
+ * tree.h: Declare them.
+
+2000-11-01 Richard Henderson <rth@redhat.com>
+
* cppmain.c (scan_buffer): Don't avoid paste for assembly.
2000-11-01 Neil Booth <neilb@earthling.net>
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index 625f726..f321063 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -487,7 +487,11 @@ genrtl_do_stmt (t)
avoids cluttering the rtl with dummy loop notes, which can affect
alignment of adjacent labels. */
if (integer_zerop (cond))
- expand_stmt (DO_BODY (t));
+ {
+ expand_start_null_loop ();
+ expand_stmt (DO_BODY (t));
+ expand_end_null_loop ();
+ }
else
{
emit_nop ();
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 9277481..fd0647a 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2294,6 +2294,30 @@ expand_start_loop_continue_elsewhere (exit_flag)
return thisloop;
}
+/* Begin a null, aka do { } while (0) "loop". But since the contents
+ of said loop can still contain a break, we must frob the loop nest. */
+
+struct nesting *
+expand_start_null_loop ()
+{
+ register struct nesting *thisloop = ALLOC_NESTING ();
+
+ /* Make an entry on loop_stack for the loop we are entering. */
+
+ thisloop->next = loop_stack;
+ thisloop->all = nesting_stack;
+ thisloop->depth = ++nesting_depth;
+ thisloop->data.loop.start_label = emit_note (NULL, NOTE_INSN_DELETED);
+ thisloop->data.loop.end_label = gen_label_rtx ();
+ thisloop->data.loop.alt_end_label = NULL_RTX;
+ thisloop->data.loop.continue_label = NULL_RTX;
+ thisloop->exit_label = thisloop->data.loop.end_label;
+ loop_stack = thisloop;
+ nesting_stack = thisloop;
+
+ return thisloop;
+}
+
/* Specify the continuation point for a loop started with
expand_start_loop_continue_elsewhere.
Use this at the point in the code to which a continue statement
@@ -2620,6 +2644,19 @@ expand_end_loop ()
last_expr_type = 0;
}
+/* Finish a null loop, aka do { } while (0). */
+
+void
+expand_end_null_loop ()
+{
+ do_pending_stack_adjust ();
+ emit_label (loop_stack->data.loop.end_label);
+
+ POPSTACK (loop_stack);
+
+ last_expr_type = 0;
+}
+
/* Generate a jump to the current loop's continue-point.
This is usually the top of the loop, but may be specified
explicitly elsewhere. If not currently inside a loop,
diff --git a/gcc/tree.h b/gcc/tree.h
index 17f09a1..2c8e1fa 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2460,8 +2460,10 @@ extern void expand_start_else PARAMS ((void));
extern void expand_start_elseif PARAMS ((tree));
extern struct nesting *expand_start_loop PARAMS ((int));
extern struct nesting *expand_start_loop_continue_elsewhere PARAMS ((int));
+extern struct nesting *expand_start_null_loop PARAMS ((void));
extern void expand_loop_continue_here PARAMS ((void));
extern void expand_end_loop PARAMS ((void));
+extern void expand_end_null_loop PARAMS ((void));
extern int expand_continue_loop PARAMS ((struct nesting *));
extern int expand_exit_loop PARAMS ((struct nesting *));
extern int expand_exit_loop_if_false PARAMS ((struct nesting *,