From patchwork Thu Jan 3 10:44:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 209209 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 A6A7E2C007E for ; Thu, 3 Jan 2013 21:45:00 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1357814701; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=07ugClsE46TIuh3UihfnKY1zOf0=; b=primevkAh8huWz4L5uSPaUMIOo5hxbDBbqhZunxD12cZ0Dmg+Zj93d4ZgH1k5B h+3EVKHGatZRD1mJRJ2Kge4kJSpJOVj2+HeElob9DumwHzwtVs868SWPE5neDnby MvqL8rsnsrgK7yR0E8r8CdrKmjOpMzJKM01aHknNRN0Oc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lQBS0F6vJbhvDaVlWH7lMUtxOuoa6SXBOnO9Xs8oFR3ZW3KtvQjwnyEYLYSY6E CWClMR44oXvio6aRQm9Kpi/elHXU6MQh1sSSpfrlY+k3c1Xu0mI+SEn6pdi7+P63 Nn6bSbR6zc7YTcN1qfxDgLhtxbTYQs8+keK2k5NBReizA=; Received: (qmail 21634 invoked by alias); 3 Jan 2013 10:44:56 -0000 Received: (qmail 21626 invoked by uid 22791); 3 Jan 2013 10:44:55 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, KHOP_THREADED, RCVD_IN_HOSTKARMA_NO, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Jan 2013 10:44:49 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r03AilMa013579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jan 2013 10:44:48 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r03AikO5029837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Jan 2013 10:44:47 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r03Aikgv029187; Thu, 3 Jan 2013 04:44:46 -0600 Received: from [192.168.1.4] (/79.17.189.139) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 Jan 2013 02:44:46 -0800 Message-ID: <50E5611C.7050100@oracle.com> Date: Thu, 03 Jan 2013 11:44:44 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Jakub Jelinek CC: "gcc-patches@gcc.gnu.org" , Jason Merrill , Tom Tromey Subject: Re: [C++ Patch] PR 54526 (again) References: <508D16AC.5070901@oracle.com> <20130102100718.GO2315@tucnak.redhat.com> In-Reply-To: <20130102100718.GO2315@tucnak.redhat.com> 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 Hi, On 01/02/2013 11:07 AM, Jakub Jelinek wrote: > Hi! > > On Sun, Oct 28, 2012 at 12:27:40PM +0100, Paolo Carlini wrote: >> --- gcc/cp/parser.c (revision 192887) >> +++ gcc/cp/parser.c (working copy) >> @@ -12655,9 +12655,8 @@ cp_parser_template_id (cp_parser *parser, >> /* Otherwise, emit an error about the invalid digraph, but continue >> parsing because we got our argument list. In C++11 do not emit >> any error, per 2.5/3. */ > Shouldn't the "In C++11 do not emit"... sentence be removed from the comment as well? > >> --- libcpp/lex.c (revision 192887) >> +++ libcpp/lex.c (working copy) >> @@ -2291,6 +2291,25 @@ _cpp_lex_direct (cpp_reader *pfile) >> if (*buffer->cur == ':') >> { >> buffer->cur++; >> + >> + /* C++11 - 2.5 p3, bullet 2. */ >> + if (CPP_OPTION (pfile, cplusplus) >> + && (CPP_OPTION (pfile, lang) == CLK_CXX11 >> + || CPP_OPTION (pfile, lang) == CLK_GNUCXX11)) >> + { >> + if (*buffer->cur == ':') >> + { >> + buffer->cur++; >> + if (*buffer->cur != ':' && *buffer->cur != '>') >> + { >> + --buffer->cur; >> + --buffer->cur; >> + break; >> + } >> + --buffer->cur; > I'd say way too many ++/-- above. I'd write it as: > > - buffer->cur++; > + > + /* C++11 - 2.5 p3, bullet 2. */ > + if (CPP_OPTION (pfile, cplusplus) > + && (CPP_OPTION (pfile, lang) == CLK_CXX11 > + || CPP_OPTION (pfile, lang) == CLK_GNUCXX11) > + && buffer->cur[1] == ':' > + && buffer->cur[2] != ':' && buffer->cur[2] != '>') > + break; > + > + buffer->cur++; Agreed, thanks for your review Jakub. Thus I booted and tested succesfully the below version of the patch. Shall we apply it or it's late for 4.8.0? Thanks! Paolo. /////////////////////// Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 194839) +++ gcc/cp/parser.c (working copy) @@ -12655,11 +12655,9 @@ cp_parser_template_id (cp_parser *parser, return error_mark_node; } /* Otherwise, emit an error about the invalid digraph, but continue - parsing because we got our argument list. In C++11 do not emit - any error, per 2.5/3. */ - if (cxx_dialect < cxx0x - && permerror (next_token->location, - "%<<::%> cannot begin a template-argument list")) + parsing because we got our argument list. */ + if (permerror (next_token->location, + "%<<::%> cannot begin a template-argument list")) { static bool hint = false; inform (next_token->location, Index: gcc/testsuite/g++.dg/cpp0x/parse2.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/parse2.C (revision 194839) +++ gcc/testsuite/g++.dg/cpp0x/parse2.C (working copy) @@ -10,3 +10,6 @@ int main() { X<::A> x; } + +int a; +bool b = 0<::a; Index: gcc/testsuite/g++.old-deja/g++.other/crash28.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.other/crash28.C (revision 194839) +++ gcc/testsuite/g++.old-deja/g++.other/crash28.C (working copy) @@ -31,5 +31,5 @@ class foo }; void foo::x() throw(bar) { - if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected" } parse error + if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected|invalid" } parse error } Index: libcpp/lex.c =================================================================== --- libcpp/lex.c (revision 194839) +++ libcpp/lex.c (working copy) @@ -2290,7 +2290,16 @@ _cpp_lex_direct (cpp_reader *pfile) { if (*buffer->cur == ':') { + /* C++11 - 2.5 p3, bullet 2. */ + if (CPP_OPTION (pfile, cplusplus) + && (CPP_OPTION (pfile, lang) == CLK_CXX11 + || CPP_OPTION (pfile, lang) == CLK_GNUCXX11) + && buffer->cur[1] == ':' + && buffer->cur[2] != ':' && buffer->cur[2] != '>') + break; + buffer->cur++; + result->flags |= DIGRAPH; result->type = CPP_OPEN_SQUARE; }