From patchwork Sat May 28 21:56:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97824 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 E4432B6F88 for ; Sun, 29 May 2011 07:56:55 +1000 (EST) Received: (qmail 10170 invoked by alias); 28 May 2011 21:56:54 -0000 Received: (qmail 10160 invoked by uid 22791); 28 May 2011 21:56:54 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 28 May 2011 21:56:39 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4SLucH5007580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 28 May 2011 17:56:38 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4SLucZV010566; Sat, 28 May 2011 17:56:38 -0400 Message-ID: <4DE16F95.9010903@redhat.com> Date: Sat, 28 May 2011 17:56:37 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List CC: Paolo Carlini Subject: Re: C++ PATCH for c++/47277 (ICE on ill-formed enum dtor) References: <4DDFFA2A.6070502@redhat.com> In-Reply-To: <4DDFFA2A.6070502@redhat.com> 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 As Paolo pointed out, our error message in this case could still be improved; this patch commits us to the pseudo-destructor interpretation if it's the only possible answer, so we get a better message about the use of an undeclared name. Tested x86_64-pc-linux-gnu, applying to trunk. commit 9ad36320078a289add9d1757428dd9b2e9725099 Author: Jason Merrill Date: Fri May 27 23:30:56 2011 -0400 PR c++/47277 * parser.c (cp_parser_pseudo_destructor_name): Commit to parse after we see the ~. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a16ba89..75ad3f8 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5642,6 +5642,11 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, /* Look for the `~'. */ cp_parser_require (parser, CPP_COMPL, RT_COMPL); + + /* Once we see the ~, this has to be a pseudo-destructor. */ + if (!processing_template_decl && !cp_parser_error_occurred (parser)) + cp_parser_commit_to_tentative_parse (parser); + /* Look for the type-name again. We are not responsible for checking that it matches the first type-name. */ *type = cp_parser_nonclass_name (parser); diff --git a/gcc/testsuite/g++.dg/cpp0x/enum18.C b/gcc/testsuite/g++.dg/cpp0x/enum18.C index 5575ca6..306ed82 100644 --- a/gcc/testsuite/g++.dg/cpp0x/enum18.C +++ b/gcc/testsuite/g++.dg/cpp0x/enum18.C @@ -2,7 +2,7 @@ // { dg-options -std=c++0x } int main(void) { - enum e {}; - e ev; - ev.e::~e_u(); // { dg-error "" } + enum e {}; + e ev; + ev.e::~e_u(); // { dg-error "e_u. has not been declared" } }