From patchwork Wed May 25 14:31:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97355 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 BC727B6F90 for ; Thu, 26 May 2011 00:31:36 +1000 (EST) Received: (qmail 16724 invoked by alias); 25 May 2011 14:31:35 -0000 Received: (qmail 16716 invoked by uid 22791); 25 May 2011 14:31:34 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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; Wed, 25 May 2011 14:31:20 +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 p4PEVKHd003005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 May 2011 10:31:20 -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 p4PEVJsO011679 for ; Wed, 25 May 2011 10:31:19 -0400 Message-ID: <4DDD12B7.8090203@redhat.com> Date: Wed, 25 May 2011 10:31:19 -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++/48935 (ICE with invalid enum scope) 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 Checking constructor_name_p doesn't work for an enum, and there's no reason to check it for non-classes anyway. The change to cp_parser_invalid_type_name is to avoid saying that a scoped enum is a class; now it will print the actual tag used in defining the type. Tested x86_64-pc-linux-gnu, applying to trunk. commit bef993e717fdccbde6acd7bde7aed2770cc1a95f Author: Jason Merrill Date: Wed May 25 01:44:53 2011 -0400 PR c++/48935 * parser.c (cp_parser_constructor_declarator_p): Don't check constructor_name_p for enums. (cp_parser_diagnose_invalid_type_name): Correct error message. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3493e44..db2cb96 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2534,7 +2534,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, "%qT is a dependent scope", parser->scope, id, parser->scope); else if (TYPE_P (parser->scope)) - error_at (location, "%qE in class %qT does not name a type", + error_at (location, "%qE in %q#T does not name a type", id, parser->scope); else gcc_unreachable (); @@ -19589,7 +19589,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) /* If we have a class scope, this is easy; DR 147 says that S::S always names the constructor, and no other qualified name could. */ if (constructor_p && nested_name_specifier - && TYPE_P (nested_name_specifier)) + && CLASS_TYPE_P (nested_name_specifier)) { tree id = cp_parser_unqualified_id (parser, /*template_keyword_p=*/false, diff --git a/gcc/testsuite/g++.dg/cpp0x/enum16.C b/gcc/testsuite/g++.dg/cpp0x/enum16.C new file mode 100644 index 0000000..ebb4868 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum16.C @@ -0,0 +1,6 @@ +// PR c++/48935 +// { dg-options -std=c++0x } + +enum class ENUM { a }; + +ENUM::Type func() { return ENUM::a; } // { dg-error "does not name a type" } diff --git a/gcc/testsuite/g++.dg/parse/error15.C b/gcc/testsuite/g++.dg/parse/error15.C index 2352193..607a1db 100644 --- a/gcc/testsuite/g++.dg/parse/error15.C +++ b/gcc/testsuite/g++.dg/parse/error15.C @@ -12,7 +12,7 @@ namespace N N::A f2; // { dg-error "1:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "1:'INVALID' in namespace 'N' does not name a type" } -N::C::INVALID f4; // { dg-error "1:'INVALID' in class 'N::C' does not name a type" } +N::C::INVALID f4; // { dg-error "1:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "1:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "13:invalid use of template-name 'N::A' without an argument list" "13" { target *-*-* } 17 } @@ -22,7 +22,7 @@ struct B { N::A f2; // { dg-error "3:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" } - N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" } + N::C::INVALID f4; // { dg-error "3:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 27 } @@ -33,7 +33,7 @@ struct C { N::A f2; // { dg-error "3:invalid use of template-name 'N::A' without an argument list" } N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" } - N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" } + N::C::INVALID f4; // { dg-error "3:'INVALID' in 'struct N::C' does not name a type" } N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } typename N::A f7; // { dg-error "15:invalid use of template-name 'N::A' without an argument list" } };