summaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-02 22:02:59 +0000
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-02 22:02:59 +0000
commit28dc567e46f5c1db5110196837094881762a6ae9 (patch)
tree8010e83f4706bb42901012ce2feacce4fc9beab5 /gcc/convert.c
parent0213c30e2883be76970abee1ec7fa1d3736799ae (diff)
downloadgcc-28dc567e46f5c1db5110196837094881762a6ae9.tar.gz
* convert.c (convert_to_pointer): Avoid recursion if no conversion
is needed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100518 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index fbd18dee23e..dc9f41f648a 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -42,10 +42,7 @@ tree
convert_to_pointer (tree type, tree expr)
{
if (integer_zerop (expr))
- {
- expr = build_int_cst (type, 0);
- return expr;
- }
+ return build_int_cst (type, 0);
switch (TREE_CODE (TREE_TYPE (expr)))
{
@@ -57,13 +54,12 @@ convert_to_pointer (tree type, tree expr)
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
case CHAR_TYPE:
- if (TYPE_PRECISION (TREE_TYPE (expr)) == POINTER_SIZE)
- return build1 (CONVERT_EXPR, type, expr);
+ if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
+ expr = fold_build1 (NOP_EXPR,
+ lang_hooks.types.type_for_size (POINTER_SIZE, 0),
+ expr);
+ return fold_build1 (CONVERT_EXPR, type, expr);
- return
- convert_to_pointer (type,
- convert (lang_hooks.types.type_for_size
- (POINTER_SIZE, 0), expr));
default:
error ("cannot convert to a pointer type");