diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 14 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 1 |
3 files changed, 18 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5fabf49..b54d930 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2006-01-20 Dirk Mueller <dmueller@suse.com> + + PR c++/5520 + * semantics.c (finish_if_stmt): Call empty_body_warning. + * parser.c (cp_parser_implicitly_scoped_statement): + Mark empty statement with an empty stmt. + 2006-01-19 Mark Mitchell <mark@codesourcery.com> PR c++/22136 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d2b41e5..cf19fbf 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6827,8 +6827,17 @@ cp_parser_implicitly_scoped_statement (cp_parser* parser) { tree statement; + /* Mark if () ; with a special NOP_EXPR. */ + if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) + { + cp_lexer_consume_token (parser->lexer); + statement = add_stmt (build_empty_stmt ()); + } + /* if a compound is opened, we simply parse the statement directly. */ + else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) + statement = cp_parser_compound_statement (parser, NULL, false); /* If the token is not a `{', then we must take special action. */ - if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)) + else { /* Create a compound-statement. */ statement = begin_compound_stmt (0); @@ -6837,9 +6846,6 @@ cp_parser_implicitly_scoped_statement (cp_parser* parser) /* Finish the dummy compound-statement. */ finish_compound_stmt (statement); } - /* Otherwise, we simply parse the statement directly. */ - else - statement = cp_parser_compound_statement (parser, NULL, false); /* Return the statement. */ return statement; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 512b789..6121d43 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -670,6 +670,7 @@ finish_if_stmt (tree if_stmt) TREE_CHAIN (if_stmt) = NULL; add_stmt (do_poplevel (scope)); finish_stmt (); + empty_body_warning (THEN_CLAUSE (if_stmt), ELSE_CLAUSE (if_stmt)); } /* Begin a while-statement. Returns a newly created WHILE_STMT if |