From patchwork Mon Feb 14 21:52: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: 83161 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 26408B70DC for ; Tue, 15 Feb 2011 08:52:30 +1100 (EST) Received: (qmail 21006 invoked by alias); 14 Feb 2011 21:52:26 -0000 Received: (qmail 20803 invoked by uid 22791); 14 Feb 2011 21:52:25 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Mon, 14 Feb 2011 21:52:19 +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 p1ELqHQj008314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Feb 2011 16:52:17 -0500 Received: from [127.0.0.1] (ovpn-113-37.phx2.redhat.com [10.3.113.37]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1ELqG4N000646 for ; Mon, 14 Feb 2011 16:52:17 -0500 Message-ID: <4D59A410.4030901@redhat.com> Date: Mon, 14 Feb 2011 16:52:16 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/47482 (C++0x ICE with sizeof) 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 turned out to be not actually a problem in the constexpr code, but rather exposed by it; if we're going to pull out the DECL_INITIAL of an enumerator CONST_DECL in integral_constant_value, we need to make sure it's folded ahead of time. Tested x86_64-pc-linux-gnu, applied to trunk. commit 7cad41e9a0ad658e8916474209983f25fa50b92e Author: Jason Merrill Date: Fri Feb 11 14:45:53 2011 -0500 PR c++/47482 * parser.c (cp_parser_enumerator_definition): Call fold_non_dependent_expr. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 11039b8..8f4a121 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13763,6 +13763,10 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type) if (check_for_bare_parameter_packs (value)) value = error_mark_node; + /* integral_constant_value will pull out this expression, so make sure + it's folded as appropriate. */ + value = fold_non_dependent_expr (value); + /* Create the enumerator. */ build_enumerator (identifier, value, type, loc); } diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C new file mode 100644 index 0000000..6e29f9e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C @@ -0,0 +1,8 @@ +// PR c++/47482 +// { dg-options -std=c++0x } + +template +struct K +{ + enum { A = sizeof"A", B = +A }; +};