From patchwork Tue Oct 5 17:09:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 66849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 031B9B70DF for ; Wed, 6 Oct 2010 04:09:32 +1100 (EST) Received: (qmail 31003 invoked by alias); 5 Oct 2010 17:09:31 -0000 Received: (qmail 30995 invoked by uid 22791); 5 Oct 2010 17:09:30 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Oct 2010 17:09:25 +0000 Received: from eggs.gnu.org ([140.186.70.92]:53471) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P3B12-0006zF-0S for gcc-patches@gnu.org; Tue, 05 Oct 2010 13:09:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3B10-00077n-1U for gcc-patches@gnu.org; Tue, 05 Oct 2010 13:09:23 -0400 Received: from smtp201.iad.emailsrvr.com ([207.97.245.201]:43825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3B0z-00077g-UF for gcc-patches@gnu.org; Tue, 05 Oct 2010 13:09:22 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp50.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 6E2A137061A for ; Tue, 5 Oct 2010 13:09:21 -0400 (EDT) Received: from dynamic4.wm-web.iad.mlsrvr.com (dynamic4.wm-web.iad1a.rsapps.net [192.168.2.153]) by smtp50.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 5C033370614 for ; Tue, 5 Oct 2010 13:09:21 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic4.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 3B2DC1D4A24C for ; Tue, 5 Oct 2010 13:09:21 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Tue, 5 Oct 2010 19:09:21 +0200 (CEST) Date: Tue, 5 Oct 2010 19:09:21 +0200 (CEST) Subject: ObjC++ bugfix for PR objc++/28050 From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1286298561.240132668@192.168.2.231> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This ObjC++ patch (to be applied on top of my other two ObjC++ patches from today) fixes PR objc++/28050, which is yet another internal compiler error (in this case, for an '@interface' with no following identifier). Thanks In gcc/testsuite/: 2010-10-05 Nicola Pero PR objc++/28050 * obj-c++.dg/syntax-error-10.mm: New. Index: obj-c++.dg/syntax-error-10.mm =================================================================== --- obj-c++.dg/syntax-error-10.mm (revision 0) +++ obj-c++.dg/syntax-error-10.mm (revision 0) @@ -0,0 +1 @@ +@interface /* { dg-error "expected identifier" } */ In gcc/cp: 2010-10-05 Nicola Pero PR objc++/31125 * parser.c (cp_parser_objc_class_interface): If no identifier follows an @interface token, stop parsing the interface after printing an error. (cp_parser_objc_class_implementation): If no identifier follows an @implementation token, stop parsing the implementation after printing an error. Index: parser.c =================================================================== --- parser.c (revision 164989) +++ parser.c (working copy) @@ -21932,6 +21976,15 @@ cp_parser_objc_class_interface (cp_parser* parser, cp_lexer_consume_token (parser->lexer); /* Eat '@interface'. */ name = cp_parser_identifier (parser); + if (name == error_mark_node) + { + /* It's hard to recover because even if valid @interface stuff + is to follow, we can't compile it (or validate it) if we + don't even know which class it refers to. Let's assume this + was a stray '@interface' token in the stream and skip it. + */ + return; + } cp_parser_objc_superclass_or_category (parser, &super, &categ); protos = cp_parser_objc_protocol_refs_opt (parser); @@ -21958,6 +22011,16 @@ cp_parser_objc_class_implementation (cp_parser* pa cp_lexer_consume_token (parser->lexer); /* Eat '@implementation'. */ name = cp_parser_identifier (parser); + if (name == error_mark_node) + { + /* It's hard to recover because even if valid @implementation + stuff is to follow, we can't compile it (or validate it) if + we don't even know which class it refers to. Let's assume + this was a stray '@implementation' token in the stream and + skip it. + */ + return; + } cp_parser_objc_superclass_or_category (parser, &super, &categ); /* We have either a class or a category on our hands. */