From patchwork Tue Oct 5 16:45:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: ObjC++ bugfix for PR objc++/23707 X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 66845 Message-Id: <1286297113.156221415@192.168.2.231> To: "gcc-patches@gnu.org" Date: Tue, 5 Oct 2010 18:45:13 +0200 (CEST) From: "Nicola Pero" List-Id: This patch (to be applied on top of the other chunk of ObjC++ bugfixes I sent earlier) fixes PR objc++/23707 (internal compiler error when a method declaration is suddenly interrupted). Ok to apply ? Thanks gcc/cp/ChangeLog: 2010-10-05 Nicola Pero PR objc++/23707 * parser.c (cp_parser_objc_method_keyword_params): If the required colon is not found while parsing parameters, stop parsing them. gcc/testsuite/obj-c++/ChangeLog: 2010-10-05 Nicola Pero PR objc++/23707 * obj-c++.dg/syntax-error.9.mm: New. Index: parser.c =================================================================== --- parser.c (revision 164989) +++ parser.c (working copy) @@ -21482,7 +21491,12 @@ cp_parser_objc_method_keyword_params (cp_parser* p } maybe_unary_selector_p = false; - cp_parser_require (parser, CPP_COLON, RT_COLON); + if (!cp_parser_require (parser, CPP_COLON, RT_COLON)) + { + /* Something went quite wrong. There should be a colon + here, but there is not. Stop parsing parameters. */ + break; + } type_name = cp_parser_objc_typename (parser); /* New ObjC allows attributes on parameters too. */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE)) Index: obj-c++.dg/syntax-error-9.mm =================================================================== --- obj-c++.dg/syntax-error-9.mm (revision 0) +++ obj-c++.dg/syntax-error-9.mm (revision 0) @@ -0,0 +1,3 @@ +@implementation SaturnDoc /* { dg-warning "cannot find interface declaration" } */ +- read: (void*)aStream ggg /* { dg-error "expected .:. at end of input" } */ +/* { dg-error "expected ..end. at end of input" "" { target *-*-* } 2 } */