From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29799 invoked by alias); 8 Nov 2011 01:22:27 -0000 Received: (qmail 29785 invoked by uid 22791); 8 Nov 2011 01:22:20 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD 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, 08 Nov 2011 01:22:07 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pA81M5qd009008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Nov 2011 01:22:06 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pA81M4Eq018133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Nov 2011 01:22:05 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pA81LwR8022823; Mon, 7 Nov 2011 19:21:59 -0600 Received: from [192.168.1.4] (/79.56.218.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Nov 2011 17:21:58 -0800 Message-ID: <4EB8842A.2040603@oracle.com> Date: Tue, 08 Nov 2011 01:42:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 50864 (parser bits) References: <4EB87866.80303@oracle.com> <4EB87CA3.9090200@redhat.com> <4EB87D11.7050908@oracle.com> In-Reply-To: <4EB87D11.7050908@oracle.com> Content-Type: multipart/mixed; boundary="------------050706090301090701040002" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01119.txt.bz2 This is a multi-part message in MIME format. --------------050706090301090701040002 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 355 On 11/08/2011 01:51 AM, Paolo Carlini wrote: >> Do we need to check the code of postfix_expression at all? > Ah! You implied that, in your previous message, but seemed too nice to > me ;) Let me regtest without... And this indeed passes testing. A rather old testcase got a slightly more accurate error message. Thanks, Paolo. ////////////////////// --------------050706090301090701040002 Content-Type: text/plain; name="CL_50864_new_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_50864_new_2" Content-length: 376 /cp 2011-11-08 Paolo Carlini PR c++/50864 * parser.c (cp_parser_postfix_dot_deref_expression): Reject invalid uses of '->' and '.' as postfix-expression in namespace scope. /testsuite 2011-11-08 Paolo Carlini PR c++/50864 * g++.dg/parse/template26.C: New. * g++.dg/template/crash45.C: Adjust dg-error string. --------------050706090301090701040002 Content-Type: text/plain; name="patch_50864_new_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_50864_new_2" Content-length: 1986 Index: testsuite/g++.dg/parse/template26.C =================================================================== --- testsuite/g++.dg/parse/template26.C (revision 0) +++ testsuite/g++.dg/parse/template26.C (revision 0) @@ -0,0 +1,18 @@ +// PR c++/50864 + +namespace impl +{ + template T create(); +} + +template ()->*impl::create())> +struct foo1; + +template ()->impl::create())> // { dg-error "not a class member" } +struct foo2; + +template ().impl::create())> // { dg-error "not a class member" } +struct foo3; Index: testsuite/g++.dg/template/crash45.C =================================================================== --- testsuite/g++.dg/template/crash45.C (revision 181138) +++ testsuite/g++.dg/template/crash45.C (working copy) @@ -9,5 +9,5 @@ namespace N void bar(A *p) { - p->N::foo<0>; // { dg-error "not a member" } + p->N::foo<0>; // { dg-error "not a class member" } } Index: cp/parser.c =================================================================== --- cp/parser.c (revision 181138) +++ cp/parser.c (working copy) @@ -5969,10 +5969,17 @@ cp_parser_postfix_dot_deref_expression (cp_parser { if (name != error_mark_node && !BASELINK_P (name) && parser->scope) { - name = build_qualified_name (/*type=*/NULL_TREE, - parser->scope, - name, - template_p); + if (TREE_CODE (parser->scope) == NAMESPACE_DECL) + { + error_at (token->location, "%<%D::%D%> is not a class member", + parser->scope, name); + postfix_expression = error_mark_node; + } + else + name = build_qualified_name (/*type=*/NULL_TREE, + parser->scope, + name, + template_p); parser->scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; --------------050706090301090701040002--