This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [varasm] patch for integer_cst non-int-sized pointer initializers


> It must have been a bad day at the office as you also didn't mention
> whether and where you'd bootstraped it, but the recent ping confirmed
> that this has been tested on some x86_64 triple.
> 
> Ok for mainline with the obvious corrections above.

I re-bootstrap-regression-tested it just in case, with the corrections
you suggested.  Patch as committed:

2006-01-20  DJ Delorie  <dj@redhat.com>

	* varasm.c (initialize_constant_valid_p): Allow pointers
	initialized from integer constants of lesser precision.
	(output_constant): Allow non-int-sized pointer modes to be
	initialized from integer constants.

Index: varasm.c
===================================================================
--- varasm.c	(revision 110040)
+++ varasm.c	(working copy)
@@ -3553,6 +3553,9 @@ initializer_constant_valid_p (tree value
 	     || TREE_CODE (dest_type) == OFFSET_TYPE)
 	    && INTEGRAL_TYPE_P (src_type))
 	  {
+	    if (TREE_CODE (src) == INTEGER_CST
+		&& TYPE_PRECISION (dest_type) >= TYPE_PRECISION (src_type))
+	      return null_pointer_node;
 	    if (integer_zerop (src))
 	      return null_pointer_node;
 	    else if (TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type))
@@ -3732,6 +3735,11 @@ output_constant (tree exp, unsigned HOST
 	 way.  */
       if (TREE_CODE (exp) == ADDR_EXPR)
 	exp = build1 (ADDR_EXPR, saved_type, TREE_OPERAND (exp, 0));
+      /* Likewise for constant ints.  */
+      else if (TREE_CODE (exp) == INTEGER_CST)
+	exp = build_int_cst_wide (saved_type, TREE_INT_CST_LOW (exp),
+				  TREE_INT_CST_HIGH (exp));
+      
     }
 
   /* Eliminate any conversions since we'll be outputting the underlying


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]