From patchwork Mon Jun 20 14:20:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 101133 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 B09F5B6F6F for ; Tue, 21 Jun 2011 00:20:57 +1000 (EST) Received: (qmail 28580 invoked by alias); 20 Jun 2011 14:20:55 -0000 Received: (qmail 28569 invoked by uid 22791); 20 Jun 2011 14:20:54 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CD, 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; Mon, 20 Jun 2011 14:20:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5KEKaIS029773 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Jun 2011 10:20:36 -0400 Received: from [127.0.0.1] ([10.3.113.2]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5KEKa6w020678 for ; Mon, 20 Jun 2011 10:20:36 -0400 Message-ID: <4DFF5733.5080308@redhat.com> Date: Mon, 20 Jun 2011 10:20:35 -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 Subject: C++ PATCH for c++/47635 (ICE after error with enum scoped function) 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 If we see an enum as a scope for a declarator-id, we should avoid setting ctype in the first place as it can't possibly be right. Tested x86_64-pc-linux-gnu, applying to trunk. commit 5800b6d699b10f0c15355b8f37fa9beb7957ea72 Author: Jason Merrill Date: Sun Jun 19 22:38:46 2011 -0400 PR c++/47635 * decl.c (grokdeclarator): Don't set ctype to an ENUMERAL_TYPE. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 85249f1..263ab3f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8338,10 +8338,15 @@ grokdeclarator (const cp_declarator *declarator, else if (TYPE_P (qualifying_scope)) { ctype = qualifying_scope; - if (innermost_code != cdk_function - && current_class_type - && !UNIQUELY_DERIVED_FROM_P (ctype, - current_class_type)) + if (!MAYBE_CLASS_TYPE_P (ctype)) + { + error ("%q#T is not a class or a namespace", ctype); + ctype = NULL_TREE; + } + else if (innermost_code != cdk_function + && current_class_type + && !UNIQUELY_DERIVED_FROM_P (ctype, + current_class_type)) { error ("type %qT is not derived from type %qT", ctype, current_class_type); @@ -9350,7 +9355,7 @@ grokdeclarator (const cp_declarator *declarator, would not have exited the loop above. */ if (declarator && declarator->u.id.qualifying_scope - && TYPE_P (declarator->u.id.qualifying_scope)) + && MAYBE_CLASS_TYPE_P (declarator->u.id.qualifying_scope)) { tree t; @@ -10156,13 +10161,6 @@ grokdeclarator (const cp_declarator *declarator, "declared out of global scope", name); } - if (ctype != NULL_TREE - && TREE_CODE (ctype) != NAMESPACE_DECL && !MAYBE_CLASS_TYPE_P (ctype)) - { - error ("%q#T is not a class or a namespace", ctype); - ctype = NULL_TREE; - } - if (ctype == NULL_TREE) { if (virtualp) diff --git a/gcc/testsuite/g++.dg/cpp0x/enum20.C b/gcc/testsuite/g++.dg/cpp0x/enum20.C new file mode 100644 index 0000000..e5dc186 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum20.C @@ -0,0 +1,5 @@ +// PR c++/47635 +// { dg-options -std=c++0x } + +enum A { }; +void A::f() { } // { dg-error "not a class" }