aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2007-12-13 11:35:02 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 11:35:02 +0100
commite4b551223d976bfa9117c3e3b9eaaaf952441db3 (patch)
tree6e5df141a80f11224996c769f6de1932b30ff110 /gcc
parent4981ffccd5f5036ee2e5f768e62d41f9be354187 (diff)
downloadgcc-e4b551223d976bfa9117c3e3b9eaaaf952441db3.zip
gcc-e4b551223d976bfa9117c3e3b9eaaaf952441db3.tar.gz
gcc-e4b551223d976bfa9117c3e3b9eaaaf952441db3.tar.bz2
s-stoele.adb ("mod"): mod negative value raises Constraint_Error
2007-12-06 Robert Dewar <dewar@adacore.com> * s-stoele.adb ("mod"): mod negative value raises Constraint_Error From-SVN: r130864
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/s-stoele.adb19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/ada/s-stoele.adb b/gcc/ada/s-stoele.adb
index 01f9fda..67aae72 100644
--- a/gcc/ada/s-stoele.adb
+++ b/gcc/ada/s-stoele.adb
@@ -47,8 +47,9 @@ package body System.Storage_Elements is
new Ada.Unchecked_Conversion (Address, Storage_Offset);
-- Conversion to/from integers
- -- Those functions must be place first because they are inlined_always
- -- and are used in other subprograms defined in this unit.
+
+ -- These functions must be place first because they are inlined_always
+ -- and are used and inlined in other subprograms defined in this unit.
function To_Integer (Value : Address) return Integer_Address is
begin
@@ -87,12 +88,18 @@ package body System.Storage_Elements is
Right : Storage_Offset) return Storage_Offset
is
begin
- if Right >= 0 then
+ if Right > 0 then
return Storage_Offset
- (To_Integer (Left) mod Integer_Address (Right));
+ (To_Integer (Left) mod Integer_Address (Right));
+
+ -- The negative case makes no sense since it is a case of a mod where
+ -- the left argument is unsigned and the right argument is signed. In
+ -- accordance with the (spirit of the) permission of RM 13.7.1(16),
+ -- we raise CE, and also include the zero case here. Yes, the RM says
+ -- PE, but this really is so obviously more like a constraint error.
+
else
- return -Storage_Offset
- ((-To_Integer (Left)) mod Integer_Address (-Right));
+ raise Constraint_Error;
end if;
end "mod";
end System.Storage_Elements;