From patchwork Tue Oct 26 14:38:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 69256 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 F1700B70CD for ; Wed, 27 Oct 2010 01:38:29 +1100 (EST) Received: (qmail 7710 invoked by alias); 26 Oct 2010 14:38:26 -0000 Received: (qmail 7545 invoked by uid 22791); 26 Oct 2010 14:38:25 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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; Tue, 26 Oct 2010 14:38:21 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9QEcJ90022676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Oct 2010 10:38:19 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9QEcISG025522; Tue, 26 Oct 2010 10:38:19 -0400 Message-ID: <4CC6E7DA.9020502@redhat.com> Date: Tue, 26 Oct 2010 10:38:18 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.14) Gecko/20101020 Lightning/1.0b1 Shredder/3.0.10pre MIME-Version: 1.0 To: gcc-patches List CC: Richard Henderson Subject: Re: RFA: PATCH to constructor_static_from_elts_p References: <4C5C6E15.6040207@redhat.com> In-Reply-To: <4C5C6E15.6040207@redhat.com> 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 On 08/06/2010 04:18 PM, Jason Merrill wrote: > Working on the C++0x constexpr branch, I noticed that > initializer_constant_valid_p was returning false for CONSTRUCTORs of > ARRAY_TYPE and ones with no elements. > > The second restriction went in in r11333, and seems to have just been to > avoid an ICE on dereferencing NULL, which is now irrelevant. > > The type restriction seems to be a holdover from when RMS first added > this code in r5921 in order to handle a special case of union casting. > Now the code is much more general, and there doesn't seem to be any > justification for retaining this restriction. > > Tested x86_64-pc-linux-gnu. OK for trunk now? OK for trunk when I merge > the constexpr branch? I'm getting ready to merge constexpr, so, ping? Jason commit f978e83eff0078e22bb702596286c708b5eb5e03 Author: Jason Merrill Date: Fri Aug 6 20:09:38 2010 +0200 * varasm.c (constructor_static_from_elts_p): Don't require a CONSTRUCTOR to have elements to be suitable for static initialization. Allow ARRAY_TYPE as well. diff --git a/gcc/varasm.c b/gcc/varasm.c index 4742304..d85e2bb 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3893,8 +3893,8 @@ constructor_static_from_elts_p (const_tree ctor) { return (TREE_CONSTANT (ctor) && (TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE - || TREE_CODE (TREE_TYPE (ctor)) == RECORD_TYPE) - && !VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (ctor))); + || TREE_CODE (TREE_TYPE (ctor)) == RECORD_TYPE + || TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE)); } static tree initializer_constant_valid_p_1 (tree value, tree endtype,