From patchwork Fri Jan 4 23:03:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 209571 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 F3CC32C008F for ; Sat, 5 Jan 2013 10:04:22 +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=1357945463; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:In-Reply-To:References:From:Date: Message-ID:Subject:To:Cc:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=LYqgvvgZKNBqcdQA/a2XmuhkAvc=; b=ePO+Be2DV8bLkoo uspZ6XYMn9owFvGVa/vTlpDs+ax+ptvn5aqtpgZ4PVubraSAxaNnvq3bd+YJacm0 ItNQutCnZMblrYWbqKvum7Y3Kk66F+lmvv3uS3GYQMwAcNkTyw3aoDX8sr3wk0IO hRYaVQUH0ncbfw7c9TvDPFlBPSGA= 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:X-Google-DKIM-Signature:Received:MIME-Version:Received:In-Reply-To:References:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-Gm-Message-State:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=IkbiVbfltCUYfOQc/+a/GD1SR0IUHAVUrXDaRL18DiI/5JcfbTHm93Qvcp8X49 hZ/jTkpEuwflEK67FO+qfBZGx+M2hlhNOVdKrYxtcDwkamlK77kC3/hoO3r/8zHn p8fZefV7HL8fsmGNSJHGR0/WuWRKNsu1WjTMCE5Nx3lCI=; Received: (qmail 16458 invoked by alias); 4 Jan 2013 23:04:13 -0000 Received: (qmail 16449 invoked by uid 22791); 4 Jan 2013 23:04:12 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f173.google.com (HELO mail-ob0-f173.google.com) (209.85.214.173) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Jan 2013 23:04:07 +0000 Received: by mail-ob0-f173.google.com with SMTP id xn12so14922726obc.4 for ; Fri, 04 Jan 2013 15:04:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=R+2GvotVFU7tWsL4qQ78LOvpDM/kzXTBfpyVik8NQ3I=; b=a5Pd1DNeQmakk9hXATc+3xlA3E2GJe9HMX64NqYJLb0igQxgLj1M2bGZOGC0owa0R1 vxkop0RcOBQurtmK7z76HloIAuqaukvHOmcuU1l4YwWgyTcLGAGtuyVg71uYH23+K5/F HOWeLFVXyKJ90okdR8atlzB+YJ93OsSR3PV7N03RbiTXE0Fv7q1Nk6mLpxLuPKxGF4xg g41t7m5Nicup/prSRV1vz88A+LiSAQakeXzdQcNGNUYzdkzBJyj9xm+vU2jLibrtQdP/ n6BkzTFytiYH36/6HsZcEYLviXijX4COWgg9EskujVVsf6Ly/tajLcIiX6Poappcd2RU lIdA== Received: by 10.182.188.36 with SMTP id fx4mr39434880obc.6.1357340646527; Fri, 04 Jan 2013 15:04:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.76.11.202 with HTTP; Fri, 4 Jan 2013 15:03:36 -0800 (PST) In-Reply-To: References: <20130104173258.9F8B81908AC@elbrus2.mtv.corp.google.com> From: Paul Pluzhnikov Date: Fri, 4 Jan 2013 15:03:36 -0800 Message-ID: Subject: Re: [google 4_7] Backport r194909 (<:: is incorrectly treated as digraph ...) to google/gcc-4_7 branch (issue7028052) To: Xinliang David Li Cc: reply@codereview.appspotmail.com, jdennet@google.com, GCC Patches X-Gm-Message-State: ALoCoQmBYXWLyMOgZdKq00VnbF2vWgW098/ZrKKWxYP+Zra8KuUseXfYckfyFcFlkUnlfRut9dTIVG1GQWu7htLBmcz0Y9H45zTmBLXRqRugv0eX67f6ofoazgjW7Yk1pN4mv1Ttwp1/JtVBXwvIjLJLOf1O8jxSZyFCXys1aOmX639pcJVNcXKU9wqpFBGxhmL/1umud08o 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 On Fri, Jan 4, 2013 at 9:41 AM, Xinliang David Li wrote: > ok. The patch as sent caused some breakage, I had to adjust test cases a bit. Submitting attached patch. Thanks, Index: gcc/testsuite/g++.old-deja/g++.other/crash28.C =================================================================== --- gcc/testsuite/g++.old-deja/g++.other/crash28.C (revision 194909) +++ gcc/testsuite/g++.old-deja/g++.other/crash28.C (working copy) @@ -31,5 +31,5 @@ }; 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: gcc/testsuite/g++.dg/parse/error12.C =================================================================== --- gcc/testsuite/g++.dg/parse/error12.C (revision 194909) +++ gcc/testsuite/g++.dg/parse/error12.C (working copy) @@ -8,6 +8,6 @@ template struct Foo {}; -Foo<::B> foo; // { dg-bogus "error" "error in place of warning" } -// { dg-warning "4: '<::' cannot begin a template-argument list" "warning <::" { target *-*-* } 11 } -// { dg-message "4:'<:' is an alternate spelling for '.'. Insert whitespace between '<' and '::'" "note <:" { target *-*-* } 11 } +Foo<::B> foo; // { dg-bogus "error" "error in place of warning" { target c++98 } } +// { dg-warning "4: '<::' cannot begin a template-argument list" "warning <::" { target c++98 } 11 } +// { dg-message "4:'<:' is an alternate spelling for '.'. Insert whitespace between '<' and '::'" "note <:" { target c++98 } 11 } Index: gcc/testsuite/g++.dg/parse/error11.C =================================================================== --- gcc/testsuite/g++.dg/parse/error11.C (revision 194909) +++ gcc/testsuite/g++.dg/parse/error11.C (working copy) @@ -16,22 +16,22 @@ }; void method(void) { - typename Foo<::B>::template Nested<::B> n; // { dg-error "17:'<::' cannot begin" "17-begin" } -// { dg-message "17:'<:' is an alternate spelling" "17-alt" { target *-*-* } 19 } -// { dg-error "39:'<::' cannot begin" "39-begin" { target *-*-* } 19 } -// { dg-message "39:'<:' is an alternate spelling" "39-alt" { target *-*-* } 19 } + typename Foo<::B>::template Nested<::B> n; // { dg-error "17:'<::' cannot begin" "17-begin" { target c++98 } } +// { dg-message "17:'<:' is an alternate spelling" "17-alt" { target c++98 } 19 } +// { dg-error "39:'<::' cannot begin" "39-begin" { target c++98 } 19 } +// { dg-message "39:'<:' is an alternate spelling" "39-alt" { target c++98 } 19 } n.template Nested::method(); - n.template Nested<::B>::method(); // { dg-error "22:'<::' cannot begin" "error" } -// { dg-message "22:'<:' is an alternate" "note" { target *-*-* } 24 } + n.template Nested<::B>::method(); // { dg-error "22:'<::' cannot begin" "error" { target c++98 } } +// { dg-message "22:'<:' is an alternate" "note" { target c++98 } 24 } Nested::method(); - Nested<::B>::method(); // { dg-error "11:'<::' cannot begin" "error" } -// { dg-message "11:'<:' is an alternate" "note" { target *-*-* } 27 } + Nested<::B>::method(); // { dg-error "11:'<::' cannot begin" "error" { target c++98 } } +// { dg-message "11:'<:' is an alternate" "note" { target c++98 } 27 } } }; template struct Foo2 {}; -template struct Foo2<::B>; // { dg-error "21:'<::' cannot begin" "begin" } -// { dg-message "21:'<:' is an alternate" "alt" { target *-*-* } 33 } +template struct Foo2<::B>; // { dg-error "21:'<::' cannot begin" "begin" { target c++98 } } +// { dg-message "21:'<:' is an alternate" "alt" { target c++98 } 33 } // { dg-message "25:type/value mismatch" "mismatch" { target *-*-* } 33 } // { dg-error "25:expected a constant" "const" { target *-*-* } 33 } @@ -39,11 +39,11 @@ void func(void) { - Foo<::B> f; // { dg-error "cannot begin" "begin" } -// { dg-message "alternate spelling" "alt" { target *-*-* } 42 } + Foo<::B> f; // { dg-error "cannot begin" "begin" { target c++98 } } +// { dg-message "alternate spelling" "alt" { target c++98 } 42 } f.Foo::method(); - f.Foo<::B>::method(); // { dg-error "8:cannot begin" "begin" } -// { dg-message "8:alternate spelling" "alt" { target *-*-* } 45 } + f.Foo<::B>::method(); // { dg-error "8:cannot begin" "begin" { target c++98 } } +// { dg-message "8:alternate spelling" "alt" { target c++98 } 45 } // Check cases where we the token sequence is the correct one, but there // was no digraph or whitespaces in the middle, so we should not emit @@ -63,9 +63,9 @@ Foo[::value] = 0; } -template struct Foo<::B>; // { dg-error "20:'<::' cannot begin" "begin" } -// { dg-message "20:is an alternate" "alt" { target *-*-* } 66 } +template struct Foo<::B>; // { dg-error "20:'<::' cannot begin" "begin" { target c++98 } } +// { dg-message "20:is an alternate" "alt" { target c++98 } 66 } // On the first error message, an additional note about the use of // -fpermissive should be present -// { dg-message "17:\\(if you use '-fpermissive' G\\+\\+ will accept your code\\)" "-fpermissive" { target *-*-* } 19 } +// { dg-message "17:\\(if you use '-fpermissive' G\\+\\+ will accept your code\\)" "-fpermissive" { target c++98 } 19 } Index: libcpp/lex.c =================================================================== --- libcpp/lex.c (revision 194909) +++ libcpp/lex.c (working copy) @@ -2224,6 +2224,17 @@ { if (*buffer->cur == ':') { + /* C++11 [2.5/3 lex.pptoken], "Otherwise, if the next + three characters are <:: and the subsequent character + is neither : nor >, the < is treated as a preprocessor + token by itself". */ + 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;