From patchwork Fri Aug 6 20:18:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 61153 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 C4D50B6F01 for ; Sat, 7 Aug 2010 06:18:45 +1000 (EST) Received: (qmail 9971 invoked by alias); 6 Aug 2010 20:18:39 -0000 Received: (qmail 9962 invoked by uid 22791); 6 Aug 2010 20:18:38 -0000 X-SWARE-Spam-Status: No, hits=-6.0 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; Fri, 06 Aug 2010 20:18:33 +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 o76KIWRA031919 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Aug 2010 16:18:32 -0400 Received: from [IPv6:::1] (ovpn-113-59.phx2.redhat.com [10.3.113.59]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o76KIV4n007534 for ; Fri, 6 Aug 2010 16:18:31 -0400 Message-ID: <4C5C6E15.6040207@redhat.com> Date: Fri, 06 Aug 2010 22:18:29 +0200 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100802 Lightning/1.0b1 Shredder/3.0.7pre MIME-Version: 1.0 To: gcc-patches List Subject: RFA: PATCH to constructor_static_from_elts_p 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 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? 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,