From patchwork Tue Sep 25 10:47:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 186766 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 76FC62C007C for ; Tue, 25 Sep 2012 20:47:45 +1000 (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=1349174865; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=xRmgVCvKwW4j5fpH8PFmZpYU01c=; b=WvjnG18rZlAhbHB vAmXE+UyFc9aHqi7rBvi/KGNwBrq3e53p062Ek6bscYLBGBpyBvpcDcWN8Zy1fGU YCNUxZ/xDXrnHcjps2qKNXVtDp2rJcgnY+b79YK5dbhXoJu7cW88hR/g7S4XXx4l wQrhItvDn9pYLiaO8yamsPEmsI0g= 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:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BiR3maeeEJ4JSPr1rmp9T9MQ7if46t+/16YffoD0UcvCxBUKUaaiVMg/onO5el 3NSaH5XH6wBI98gFM7M8FEi84q9Sbq35u3+6Pi3K7ZqZaAX0wQpnz79pOiKUjReO uR63c/DoBz5fX6Zp+wImh5DQ0kgW/ht9eOvl+6EEK6hGc=; Received: (qmail 11253 invoked by alias); 25 Sep 2012 10:47:41 -0000 Received: (qmail 11228 invoked by uid 22791); 25 Sep 2012 10:47:39 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, TW_CX X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Sep 2012 10:47:24 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q8PAlLdV030861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 25 Sep 2012 10:47:22 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q8PAlK2l002882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Sep 2012 10:47:21 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q8PAlKrK029879; Tue, 25 Sep 2012 05:47:20 -0500 Received: from [192.168.1.4] (/79.52.234.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 25 Sep 2012 03:47:20 -0700 Message-ID: <50618BB6.5070601@oracle.com> Date: Tue, 25 Sep 2012 12:47:18 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 54526 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, if I understand correctly, in C++11 mode we should simply accept what we used to accept only with -fpermissive. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2012-09-25 Paolo Carlini PR c++/54526 * parser.c (cp_parser_template_id): In C++11 mode simply accept X<::A>. /testsuite 2012-09-25 Paolo Carlini PR c++/54526 * g++.dg/cpp0x/parse2.C: New. * g++.dg/parse/error11.C: Adjust. * g++.dg/parse/error12.C: Likewise. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 191695) +++ cp/parser.c (working copy) @@ -12479,9 +12479,11 @@ 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. */ - if (permerror (next_token->location, - "%<<::%> cannot begin a template-argument list")) + 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")) { static bool hint = false; inform (next_token->location, Index: testsuite/g++.dg/parse/error11.C =================================================================== --- testsuite/g++.dg/parse/error11.C (revision 191695) +++ testsuite/g++.dg/parse/error11.C (working copy) @@ -16,22 +16,22 @@ struct Foo }; 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 @@ int value = 0; 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 @@ void func(void) 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: testsuite/g++.dg/parse/error12.C =================================================================== --- testsuite/g++.dg/parse/error12.C (revision 191695) +++ testsuite/g++.dg/parse/error12.C (working copy) @@ -8,6 +8,6 @@ struct B; 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: testsuite/g++.dg/cpp0x/parse2.C =================================================================== --- testsuite/g++.dg/cpp0x/parse2.C (revision 0) +++ testsuite/g++.dg/cpp0x/parse2.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/54526 +// { dg-do compile { target c++11 } } + +template +struct X { }; + +struct A { }; + +int main() +{ + X<::A> x; +}