aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorThomas Quinot <quinot@adacore.com>2008-11-07 10:17:40 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-11-07 10:17:40 +0000
commit9ed0e4832cd4956012baf9fff96db6f61ecf3515 (patch)
tree40c3631ee74a2176896062037e0000a12fec4e2c /gcc/ada
parentf0f91b6438b152d7c32bedc158ae5e79d7815cf7 (diff)
downloadgcc-9ed0e4832cd4956012baf9fff96db6f61ecf3515.zip
gcc-9ed0e4832cd4956012baf9fff96db6f61ecf3515.tar.gz
gcc-9ed0e4832cd4956012baf9fff96db6f61ecf3515.tar.bz2
trans.c (Attribute_to_gnu, [...]): Check for empty range in original base type, not converted result type.
* gcc-interface/trans.c (Attribute_to_gnu, case Attr_Length): Check for empty range in original base type, not converted result type. From-SVN: r141670
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/trans.c9
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3cb89a6..8dadc3d 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-07 Thomas Quinot <quinot@adacore.com>
+
+ * gcc-interface/trans.c (Attribute_to_gnu, case Attr_Length): Check
+ for empty range in original base type, not converted result type.
+
2008-11-07 Geert Bosch <bosch@adacore.com>
* gcc-interface/trans.c (build_binary_op_trapv): Convert arguments
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 005d517..7a82004 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -1287,7 +1287,10 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
much rarer cases, for extremely large arrays we expect
never to encounter in practice. In addition, the former
computation required the use of potentially constraining
- signed arithmetic while the latter doesn't. */
+ signed arithmetic while the latter doesn't. Note that the
+ comparison must be done in the original index base type,
+ otherwise the conversion of either bound to gnu_compute_type
+ may overflow. */
tree gnu_compute_type = get_base_type (gnu_result_type);
@@ -1301,7 +1304,9 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
gnu_result
= build3
(COND_EXPR, gnu_compute_type,
- build_binary_op (LT_EXPR, gnu_compute_type, hb, lb),
+ build_binary_op (LT_EXPR, get_base_type (index_type),
+ TYPE_MAX_VALUE (index_type),
+ TYPE_MIN_VALUE (index_type)),
convert (gnu_compute_type, integer_zero_node),
build_binary_op
(PLUS_EXPR, gnu_compute_type,