From 971dfb9b990c519338d5c497be7924f102a09a11 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Fri, 20 Jan 2006 16:55:41 -0500 Subject: varasm.c (initialize_constant_valid_p): Allow pointers initialized from integer constants of lesser precision. * 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. From-SVN: r110041 --- gcc/varasm.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/varasm.c') diff --git a/gcc/varasm.c b/gcc/varasm.c index 05bfabf..5e42b07 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3553,6 +3553,9 @@ initializer_constant_valid_p (tree value, tree endtype) || 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_WIDE_INT size, unsigned int align) 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 -- cgit v1.1