diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2010-11-14 13:10:41 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2010-11-14 13:10:41 +0000 |
commit | a5812bdc55ed682d3dbc166cddd273f4edea0b0b (patch) | |
tree | 4e246b3e80d5dc1a3504b96a42dad8946d9320d6 /gcc | |
parent | ae788515d2b28952fdee5a83b010667dc9285732 (diff) | |
download | gcc-a5812bdc55ed682d3dbc166cddd273f4edea0b0b.zip gcc-a5812bdc55ed682d3dbc166cddd273f4edea0b0b.tar.gz gcc-a5812bdc55ed682d3dbc166cddd273f4edea0b0b.tar.bz2 |
re PR c/46462 (Revision 166700 caused new C test failures)
2010-11-13 Paolo Bonzini <bonzini@gnu.org>
PR c/46462
* c-decl.c (declspecs_add_type): Make variables with error types
integers.
* c-parser.c (c_parser_next_tokens_start_declaration): Two IDs
do not start a declaration before an Objective-C foreach.
(c_parser_declaration_or_fndef): Improve recovery after unknown
type name.
(c_parser_for_statement): Hoist entrance of "foreach context"
before ifs, add corresponding reset where it was missing. Do
not set objc_could_be_foreach_context for C.
From-SVN: r166732
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/c-decl.c | 5 | ||||
-rw-r--r-- | gcc/c-parser.c | 15 |
3 files changed, 29 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d479393..ea3e335 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2010-11-13 Paolo Bonzini <bonzini@gnu.org> + + PR c/46462 + * c-decl.c (declspecs_add_type): Make variables with error types + integers. + * c-parser.c (c_parser_next_tokens_start_declaration): Two IDs + do not start a declaration before an Objective-C foreach. + (c_parser_declaration_or_fndef): Improve recovery after unknown + type name. + (c_parser_for_statement): Hoist entrance of "foreach context" + before ifs, add corresponding reset where it was missing. Do + not set objc_could_be_foreach_context for C. + 2010-11-14 Eric Botcazou <ebotcazou@adacore.com> PR tree-optimization/45722 @@ -94,7 +107,7 @@ Check that the pubtypes table has at least one unpruned entry before trying to emit it. -2010-10-30 Paolo Bonzini <bonzini@gnu.org> +2010-11-13 Paolo Bonzini <bonzini@gnu.org> PR c/20385 * c-parser.c (c_parser_next_token_starts_declaration): Rename to... diff --git a/gcc/c-decl.c b/gcc/c-decl.c index c0d5a49..bab402d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -9324,6 +9324,11 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, } specs->type = type; } + else + { + /* Set a dummy type here to avoid warning about implicit 'int'. */ + specs->type = integer_type_node; + } return specs; } diff --git a/gcc/c-parser.c b/gcc/c-parser.c index e5ec2d9..577528d 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -641,7 +641,10 @@ c_parser_next_tokens_start_declaration (c_parser *parser) && token->id_kind == C_ID_ID && (c_parser_peek_2nd_token (parser)->type == CPP_NAME || c_parser_peek_2nd_token (parser)->type == CPP_MULT) - && !lookup_name (token->value)) + && !lookup_name (token->value) + + /* Do not try too hard when we could have "object in array". */ + && !parser->objc_could_be_foreach_context) return true; return false; @@ -1373,10 +1376,12 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, c_parser_peek_token (parser)->value); /* Parse declspecs normally to get a correct pointer type, but avoid - a further "fails to be a type name" error. */ + a further "fails to be a type name" error. Refuse nested functions + since it is not how the user likely wants us to recover. */ c_parser_peek_token (parser)->type = CPP_KEYWORD; c_parser_peek_token (parser)->keyword = RID_VOID; c_parser_peek_token (parser)->value = error_mark_node; + fndef_ok = !nested; } c_parser_declspecs (parser, specs, true, true, start_attr_ok); @@ -4653,14 +4658,15 @@ c_parser_for_statement (c_parser *parser) { /* Parse the initialization declaration or expression. */ object_expression = error_mark_node; + parser->objc_could_be_foreach_context = c_dialect_objc (); if (c_parser_next_token_is (parser, CPP_SEMICOLON)) { + parser->objc_could_be_foreach_context = false; c_parser_consume_token (parser); c_finish_expr_stmt (loc, NULL_TREE); } else if (c_parser_next_tokens_start_declaration (parser)) { - parser->objc_could_be_foreach_context = true; c_parser_declaration_or_fndef (parser, true, true, true, true, true, &object_expression); parser->objc_could_be_foreach_context = false; @@ -4690,7 +4696,6 @@ c_parser_for_statement (c_parser *parser) int ext; ext = disable_extension_diagnostics (); c_parser_consume_token (parser); - parser->objc_could_be_foreach_context = true; c_parser_declaration_or_fndef (parser, true, true, true, true, true, &object_expression); parser->objc_could_be_foreach_context = false; @@ -4714,7 +4719,6 @@ c_parser_for_statement (c_parser *parser) init_expr: { tree init_expression; - parser->objc_could_be_foreach_context = true; init_expression = c_parser_expression (parser).value; parser->objc_could_be_foreach_context = false; if (c_parser_next_token_is_keyword (parser, RID_IN)) @@ -4735,6 +4739,7 @@ c_parser_for_statement (c_parser *parser) } /* Parse the loop condition. In the case of a foreach statement, there is no loop condition. */ + gcc_assert (!parser->objc_could_be_foreach_context); if (!is_foreach_statement) { if (c_parser_next_token_is (parser, CPP_SEMICOLON)) |