diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2021-01-25 19:22:39 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-07 05:28:55 -0400 |
commit | fb246154cdeb518b8e8a584032afbda4d381a03b (patch) | |
tree | 34efcaafc88ca938eb12f6ba38381c2c8cefbfbb /gcc | |
parent | 0e1e07728074a7162c8173abd10bc32e814ea254 (diff) | |
download | gcc-fb246154cdeb518b8e8a584032afbda4d381a03b.zip gcc-fb246154cdeb518b8e8a584032afbda4d381a03b.tar.gz gcc-fb246154cdeb518b8e8a584032afbda4d381a03b.tar.bz2 |
[Ada] Raise Constraint_Error for Compose and Scaling if Machine_Overflows
gcc/ada/
* libgnat/s-fatgen.adb (Scaling): Raise Constraint_Error in the
overflow case when T'Machine_Overflows is True.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/libgnat/s-fatgen.adb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb index ec376e7..e591cca 100644 --- a/gcc/ada/libgnat/s-fatgen.adb +++ b/gcc/ada/libgnat/s-fatgen.adb @@ -771,12 +771,19 @@ package body System.Fat_Gen is -- Check for overflow if Adjustment > IEEE_Emax - Exp then - XX := 0.0; - return (if Minus then -1.0 / XX else 1.0 / XX); - pragma Annotate - (CodePeer, Intentional, "overflow check", "Infinity produced"); - pragma Annotate - (CodePeer, Intentional, "divide by zero", "Infinity produced"); + -- Optionally raise Constraint_Error as per RM A.5.3(29) + + if T'Machine_Overflows then + raise Constraint_Error with "Too large exponent"; + + else + XX := 0.0; + return (if Minus then -1.0 / XX else 1.0 / XX); + pragma Annotate (CodePeer, Intentional, "overflow check", + "Infinity produced"); + pragma Annotate (CodePeer, Intentional, "divide by zero", + "Infinity produced"); + end if; -- Check for underflow |