aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2002-01-04 11:42:56 -0700
committerJeff Law <law@gcc.gnu.org>2002-01-04 11:42:56 -0700
commitc1e14513edf89b72b98db061aae226be5f14c17a (patch)
tree8720096cbd63038754878a0595c00744ebf6abdf /gcc/c-common.c
parent3b007b5d6bcefa3c87a920e834a7b1d0a34f38e5 (diff)
downloadgcc-c1e14513edf89b72b98db061aae226be5f14c17a.zip
gcc-c1e14513edf89b72b98db061aae226be5f14c17a.tar.gz
gcc-c1e14513edf89b72b98db061aae226be5f14c17a.tar.bz2
c-common.c (c_expand_start_cond): Expect the IF_STMT node to be passed in, do not build it.
* c-common.c (c_expand_start_cond): Expect the IF_STMT node to be passed in, do not build it. (c_begin_if_stmt): New function. (c_begin_while_stmt, c_finish_while_stmt_cond): Likewise. * c-common.h (c_expand_start_cond): Update prototype. (c_begin_if_stmt): Prototype new function. (c_begin_while_stmt, c_finish_while_stmt_cond): Likewise. * c-parse.in (if_prefix): Use c_begin_if_stmt, c_begin_while_stmt and c_finish_while_stmt_cond. From-SVN: r48539
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index f5f4487..b08ef5b 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -268,15 +268,20 @@ static int if_stack_space = 0;
static int if_stack_pointer = 0;
/* Record the start of an if-then, and record the start of it
- for ambiguous else detection. */
+ for ambiguous else detection.
+
+ COND is the condition for the if-then statement.
+
+ IF_STMT is the statement node that has already been created for
+ this if-then statement. It is created before parsing the
+ condition to keep line number information accurate. */
void
-c_expand_start_cond (cond, compstmt_count)
+c_expand_start_cond (cond, compstmt_count, if_stmt)
tree cond;
int compstmt_count;
+ tree if_stmt;
{
- tree if_stmt;
-
/* Make sure there is enough space on the stack. */
if (if_stack_space == 0)
{
@@ -289,7 +294,6 @@ c_expand_start_cond (cond, compstmt_count)
if_stack = (if_elt *) xrealloc (if_stack, if_stack_space * sizeof (if_elt));
}
- if_stmt = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
IF_COND (if_stmt) = cond;
add_stmt (if_stmt);
@@ -355,6 +359,46 @@ c_finish_else ()
RECHAIN_STMTS (if_stmt, ELSE_CLAUSE (if_stmt));
}
+/* Begin an if-statement. Returns a newly created IF_STMT if
+ appropriate.
+
+ Unlike the C++ front-end, we do not call add_stmt here; it is
+ probably safe to do so, but I am not very familiar with this
+ code so I am being extra careful not to change its behavior
+ beyond what is strictly necessary for correctness. */
+
+tree
+c_begin_if_stmt ()
+{
+ tree r;
+ r = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
+ return r;
+}
+
+/* Begin a while statement. Returns a newly created WHILE_STMT if
+ appropriate.
+
+ Unlike the C++ front-end, we do not call add_stmt here; it is
+ probably safe to do so, but I am not very familiar with this
+ code so I am being extra careful not to change its behavior
+ beyond what is strictly necessary for correctness. */
+
+tree
+c_begin_while_stmt ()
+{
+ tree r;
+ r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
+ return r;
+}
+
+void
+c_finish_while_stmt_cond (cond, while_stmt)
+ tree while_stmt;
+ tree cond;
+{
+ WHILE_COND (while_stmt) = cond;
+}
+
/* Push current bindings for the function name VAR_DECLS. */
void