summaryrefslogtreecommitdiff
path: root/gcc/ada/s-valrea.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/s-valrea.adb')
-rw-r--r--gcc/ada/s-valrea.adb27
1 files changed, 21 insertions, 6 deletions
diff --git a/gcc/ada/s-valrea.adb b/gcc/ada/s-valrea.adb
index 847777249e5..2e8306aabdc 100644
--- a/gcc/ada/s-valrea.adb
+++ b/gcc/ada/s-valrea.adb
@@ -89,6 +89,10 @@ package body System.Val_Real is
-- necessarily required in a case like this where the result is not
-- a machine number, but it is certainly a desirable behavior.
+ procedure Bad_Based_Value;
+ pragma No_Return (Bad_Based_Value);
+ -- Raise exception for bad based value
+
procedure Scanf;
-- Scans integer literal value starting at current character position.
-- For each digit encountered, Uval is multiplied by 10.0, and the new
@@ -98,6 +102,16 @@ package body System.Val_Real is
-- return P points past the last character. On entry, the current
-- character is known to be a digit, so a numeral is definitely present.
+ ---------------------
+ -- Bad_Based_Value --
+ ---------------------
+
+ procedure Bad_Based_Value is
+ begin
+ raise Constraint_Error with
+ "invalid based literal for 'Value";
+ end Bad_Based_Value;
+
-----------
-- Scanf --
-----------
@@ -181,7 +195,8 @@ package body System.Val_Real is
-- Any other initial character is an error
else
- raise Constraint_Error;
+ raise Constraint_Error with
+ "invalid character in 'Value string";
end if;
-- Deal with based case
@@ -219,7 +234,7 @@ package body System.Val_Real is
loop
if P > Max then
- raise Constraint_Error;
+ Bad_Based_Value;
elsif Str (P) in Digs then
Digit := Character'Pos (Str (P)) - Character'Pos ('0');
@@ -233,7 +248,7 @@ package body System.Val_Real is
Character'Pos (Str (P)) - (Character'Pos ('a') - 10);
else
- raise Constraint_Error;
+ Bad_Based_Value;
end if;
-- Save up trailing zeroes after the decimal point
@@ -267,7 +282,7 @@ package body System.Val_Real is
P := P + 1;
if P > Max then
- raise Constraint_Error;
+ Bad_Based_Value;
elsif Str (P) = '_' then
Scan_Underscore (Str, P, Ptr, Max, True);
@@ -282,7 +297,7 @@ package body System.Val_Real is
After_Point := 1;
if P > Max then
- raise Constraint_Error;
+ Bad_Based_Value;
end if;
end if;
@@ -358,7 +373,7 @@ package body System.Val_Real is
-- Here is where we check for a bad based number
if Bad_Base then
- raise Constraint_Error;
+ Bad_Based_Value;
-- If OK, then deal with initial minus sign, note that this processing
-- is done even if Uval is zero, so that -0.0 is correctly interpreted.