diff options
author | Richard Guenther <rguenther@suse.de> | 2008-11-19 17:38:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-11-19 17:38:15 +0000 |
commit | 9866586167b7591ff1bbfe59ccdeba1dad796246 (patch) | |
tree | ff9eb564008c7a7510b130d8f124d17e3259003c /gcc/expr.c | |
parent | 059c51ecb4201c53acc659543e00fc7e2586ef82 (diff) | |
download | gcc-9866586167b7591ff1bbfe59ccdeba1dad796246.tar.gz |
tree.c (build2_stat): Allow non-POINTER_PLUS_EXPRs with non-sizetype offsets if...
2008-11-19 Richard Guenther <rguenther@suse.de>
* tree.c (build2_stat): Allow non-POINTER_PLUS_EXPRs with
non-sizetype offsets if their precision matches that of
the pointer.
* expr.c (expand_expr_real_1): Always sign-extend the offset
operand of a POINTER_PLUS_EXPR.
From-SVN: r142009
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index 31af3aa9c49..0f46b199883 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8334,6 +8334,14 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, /* Even though the sizetype mode and the pointer's mode can be different expand is able to handle this correctly and get the correct result out of the PLUS_EXPR code. */ + /* Make sure to sign-extend the sizetype offset in a POINTER_PLUS_EXPR + if sizetype precision is smaller than pointer precision. */ + if (TYPE_PRECISION (sizetype) < TYPE_PRECISION (type)) + exp = build2 (PLUS_EXPR, type, + TREE_OPERAND (exp, 0), + fold_convert (type, + fold_convert (ssizetype, + TREE_OPERAND (exp, 1)))); case PLUS_EXPR: /* Check if this is a case for multiplication and addition. */ |