From patchwork Fri Aug 6 20:18:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: RFA: PATCH to constructor_static_from_elts_p Date: Fri, 06 Aug 2010 10:18:29 -0000 From: Jason Merrill X-Patchwork-Id: 61153 Message-Id: <4C5C6E15.6040207@redhat.com> To: gcc-patches List 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,