aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2006-01-20 16:55:41 -0500
committerDJ Delorie <dj@gcc.gnu.org>2006-01-20 16:55:41 -0500
commit971dfb9b990c519338d5c497be7924f102a09a11 (patch)
treee6b2cd9444ff052613192a8e567a152fa895fa8e /gcc/varasm.c
parentb615db81a92dd122cf4cc948cc07f9f6f095388d (diff)
downloadgcc-971dfb9b990c519338d5c497be7924f102a09a11.zip
gcc-971dfb9b990c519338d5c497be7924f102a09a11.tar.gz
gcc-971dfb9b990c519338d5c497be7924f102a09a11.tar.bz2
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
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c8
1 files changed, 8 insertions, 0 deletions
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