diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-07 07:59:37 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-07 07:59:37 +0000 |
commit | 080ec2e380fb58bb76a9441199538f99f59f54ff (patch) | |
tree | 2d34e06df5858f596a6c1f4f8535dbf329150335 /gcc/ada/gcc-interface/decl.c | |
parent | 7c2917323a76436a39cc319611ee024b426bd05d (diff) | |
download | gcc-080ec2e380fb58bb76a9441199538f99f59f54ff.tar.gz |
PR ada/56474
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Use
int_const_binop to shift bounds by 1 when they are integer constants.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198663 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index e65701b9a05..98653243b80 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -2447,15 +2447,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_orig_max, gnu_orig_min), gnu_min, - size_binop (PLUS_EXPR, gnu_max, - size_one_node)); + int_const_binop (PLUS_EXPR, gnu_max, + size_one_node)); } /* Finally we use (hb >= lb) ? hb : lb - 1 for the upper bound in all the other cases. Note that, here as well as above, the condition used in the comparison must be equivalent to the condition (length != 0). This is relied upon in order - to optimize array comparisons in compare_arrays. */ + to optimize array comparisons in compare_arrays. Moreover + we use int_const_binop for the shift by 1 if the bound is + constant to avoid any unwanted overflow. */ else gnu_high = build_cond_expr (sizetype, @@ -2464,8 +2466,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_orig_max, gnu_orig_min), gnu_max, - size_binop (MINUS_EXPR, gnu_min, - size_one_node)); + TREE_CODE (gnu_min) == INTEGER_CST + ? int_const_binop (MINUS_EXPR, gnu_min, + size_one_node) + : size_binop (MINUS_EXPR, gnu_min, + size_one_node)); /* Reuse the index type for the range type. Then make an index type with the size range in sizetype. */ |