From patchwork Thu Mar 17 02:30:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 87330 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 30DDBB6FD5 for ; Thu, 17 Mar 2011 13:30:48 +1100 (EST) Received: (qmail 31026 invoked by alias); 17 Mar 2011 02:30:46 -0000 Received: (qmail 31018 invoked by uid 22791); 17 Mar 2011 02:30:45 -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; Thu, 17 Mar 2011 02:30:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2H2Ue5o008650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Mar 2011 22:30:40 -0400 Received: from [127.0.0.1] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2H2UaO4016149 for ; Wed, 16 Mar 2011 22:30:39 -0400 Message-ID: <4D81724C.4010905@redhat.com> Date: Wed, 16 Mar 2011 22:30:36 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/47301 (ICE with constexpr, array and -fabi-version=1) 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 The code for backwards-compatibility with ABI v1 didn't do too well with the case of a literal class used as an array bound; it built up an integral MINUS_EXPR with it directly, which doesn't make much sense. But since 3.2 didn't support constexpr, we can just disable the v1 semantics when we are dealing with a literal class. Tested x86_64-pc-linux-gnu, applying to trunk. commit 59ffa184c154ed0676af737645f6b0a34f49dc02 Author: Jason Merrill Date: Wed Mar 16 21:12:23 2011 -0400 PR c++/47301 * decl.c (compute_array_index_type): Don't bother trying to deal with literal classes in ABI v1. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 17b3163..a7da574 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7525,6 +7525,9 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) if (size == error_mark_node) return error_mark_node; type = TREE_TYPE (size); + /* We didn't support this case in GCC 3.2, so don't bother + trying to model it now in ABI v1. */ + abi_1_itype = error_mark_node; } size = maybe_constant_value (size); @@ -7569,7 +7572,8 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) return itype; } - if (!abi_version_at_least (2) && processing_template_decl) + if (!abi_version_at_least (2) && processing_template_decl + && abi_1_itype == NULL_TREE) /* For abi-1, we handled all instances in templates the same way, even when they were non-dependent. This affects the manglings produced. So, we do the normal checking for non-dependent @@ -7683,7 +7687,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) } /* Create and return the appropriate index type. */ - if (abi_1_itype) + if (abi_1_itype && abi_1_itype != error_mark_node) { tree t = build_index_type (itype); TYPE_CANONICAL (abi_1_itype) = TYPE_CANONICAL (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C new file mode 100644 index 0000000..e83f142 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-abi1.C @@ -0,0 +1,16 @@ +// PR c++/47301 +// { dg-options "-std=c++0x -fabi-version=1" } + +struct A +{ + constexpr operator int () + { + return 1; + } +}; + +template < int > struct B +{ + static constexpr A a = A(); + int ar[a]; +};