Patchwork RFA: PATCH to constructor_static_from_elts_p

login
register
mail settings
Submitter Jason Merrill
Date Oct. 26, 2010, 2:38 p.m.
Message ID <4CC6E7DA.9020502@redhat.com>
Download mbox | patch
Permalink /patch/69256/
State New
Headers show

Comments

Jason Merrill - Oct. 26, 2010, 2:38 p.m.
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
Richard Henderson - Oct. 31, 2010, 10:03 p.m.
On 10/26/2010 07:38 AM, Jason Merrill wrote:
>     	* 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.

Ok.


r~

Patch

commit f978e83eff0078e22bb702596286c708b5eb5e03
Author: Jason Merrill <jason@redhat.com>
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,