From patchwork Sat Dec 17 19:26:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 132019 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 34249B6F9F for ; Sun, 18 Dec 2011 06:26:39 +1100 (EST) Received: (qmail 23342 invoked by alias); 17 Dec 2011 19:26:37 -0000 Received: (qmail 23334 invoked by uid 22791); 17 Dec 2011 19:26:36 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 17 Dec 2011 19:26: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 pBHJQJJu012050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 17 Dec 2011 14:26:19 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBHJQJna022875 for ; Sat, 17 Dec 2011 14:26:19 -0500 Received: from [0.0.0.0] (ovpn-113-21.phx2.redhat.com [10.3.113.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pBHJQHCQ023815 for ; Sat, 17 Dec 2011 14:26:18 -0500 Message-ID: <4EECECD8.8060306@redhat.com> Date: Sat, 17 Dec 2011 14:26:16 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111112 Thunderbird/8.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51587 (ICE with struct/enum conflict) 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 This testcase was aborting when we tried to check ENUM_UNDERLYING_TYPE on a non-enum. Fixed by checking the tree code first. Tested x86_64-pc-linux-gnu, applying to trunk. commit b01c647f6754097ac85e4ca1d7c80c1da8edc660 Author: Jason Merrill Date: Sat Dec 17 09:30:43 2011 -0500 PR c++/51587 * decl.c (start_enum): Avoid using ENUM_UNDERLYING_TYPE on a non-enum. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fedc52c..0a43fb8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12069,6 +12069,7 @@ start_enum (tree name, tree enumtype, tree underlying_type, /* Do not push the decl more than once, unless we need to compare underlying types at instantiation time */ if (!enumtype + || TREE_CODE (enumtype) != ENUMERAL_TYPE || (underlying_type && dependent_type_p (underlying_type)) || (ENUM_UNDERLYING_TYPE (enumtype) diff --git a/gcc/testsuite/g++.dg/parse/enum6.C b/gcc/testsuite/g++.dg/parse/enum6.C new file mode 100644 index 0000000..e753f51 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/enum6.C @@ -0,0 +1,8 @@ +// PR c++/51587 + +namespace N +{ + struct X; // { dg-message "previous declaration" } +} + +enum N::X {}; // { dg-error "conflicting declaration" }