summaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-04 18:42:56 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-04 18:42:56 +0000
commite87da6ae80ffef6593d86397b4971088a0ee8be0 (patch)
tree8720096cbd63038754878a0595c00744ebf6abdf /gcc/c-parse.in
parent51a555a4a3e01f09dbbfe8ab2aeca0765ebd713b (diff)
downloadgcc-e87da6ae80ffef6593d86397b4971088a0ee8be0.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48539 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in34
1 files changed, 27 insertions, 7 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 889425e26c2..9434a2fa9ff 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -2186,13 +2186,23 @@ simple_if:
;
if_prefix:
- IF '(' expr ')'
- { c_expand_start_cond (truthvalue_conversion ($3),
- compstmt_count);
+ /* We must build the IF_STMT node before parsing its
+ condition so that STMT_LINENO refers to the line
+ containing the "if", and not the line containing
+ the close-parenthesis.
+
+ c_begin_if_stmt returns the IF_STMT node, which
+ we later pass to c_expand_start_cond to fill
+ in the condition and other tidbits. */
+ IF
+ { $<ttype>$ = c_begin_if_stmt (); }
+ '(' expr ')'
+ { c_expand_start_cond (truthvalue_conversion ($4),
+ compstmt_count,$<ttype>2);
$<itype>$ = stmt_count;
if_stmt_file = $<filename>-2;
if_stmt_line = $<lineno>-1; }
- ;
+ ;
/* This is a subroutine of stmt.
It is used twice, once for valid DO statements
@@ -2287,12 +2297,22 @@ select_or_iter_stmt:
Otherwise a crash is likely. */
| simple_if ELSE error
{ c_expand_end_cond (); }
+ /* We must build the WHILE_STMT node before parsing its
+ condition so that STMT_LINENO refers to the line
+ containing the "while", and not the line containing
+ the close-parenthesis.
+
+ c_begin_while_stmt returns the WHILE_STMT node, which
+ we later pass to c_finish_while_stmt_cond to fill
+ in the condition and other tidbits. */
| WHILE
- { stmt_count++; }
+ { stmt_count++;
+ $<ttype>$ = c_begin_while_stmt (); }
'(' expr ')'
{ $4 = truthvalue_conversion ($4);
- $<ttype>$
- = add_stmt (build_stmt (WHILE_STMT, $4, NULL_TREE)); }
+ c_finish_while_stmt_cond (truthvalue_conversion ($4),
+ $<ttype>2);
+ $<ttype>$ = add_stmt ($<ttype>2); }
c99_block_lineno_labeled_stmt
{ RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
| do_stmt_start