aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-11-19 17:38:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-11-19 17:38:15 +0000
commit9866586167b7591ff1bbfe59ccdeba1dad796246 (patch)
treeff9eb564008c7a7510b130d8f124d17e3259003c /gcc/tree.c
parent059c51ecb4201c53acc659543e00fc7e2586ef82 (diff)
downloadgcc-9866586167b7591ff1bbfe59ccdeba1dad796246.zip
gcc-9866586167b7591ff1bbfe59ccdeba1dad796246.tar.gz
gcc-9866586167b7591ff1bbfe59ccdeba1dad796246.tar.bz2
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/tree.c')
-rw-r--r--gcc/tree.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 184d247..e74b779 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3289,8 +3289,13 @@ build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
gcc_assert (TREE_CODE_LENGTH (code) == 2);
if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
- && arg0 && arg1 && tt && POINTER_TYPE_P (tt))
- gcc_assert (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST);
+ && arg0 && arg1 && tt && POINTER_TYPE_P (tt)
+ /* When sizetype precision doesn't match that of pointers
+ we need to be able to build explicit extensions or truncations
+ of the offset argument. */
+ && TYPE_PRECISION (sizetype) == TYPE_PRECISION (tt))
+ gcc_assert (TREE_CODE (arg0) == INTEGER_CST
+ && TREE_CODE (arg1) == INTEGER_CST);
if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))