From: Piotr Trojanek <[email protected]>
When statically evaluating floating-point expressions we convert the final
result to machine number. However, we skipped this conversion if the result was
zero.
This inconsistency was introduced when adding a warning for compile-time
evaluation that gives different result from a run-time evaluation, but left
when this warning was deconstructed. It causes a crash in GNATprove, which
expects all floating-point numbers in the GNAT AST to be in a machine
representation form.
gcc/ada/ChangeLog:
* sem_eval.adb (Check_Non_Static_Context): Remove special handling of
floating-point zero.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_eval.adb | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index 5d150636495..f5cd0449d61 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -574,13 +574,11 @@ package body Sem_Eval is
Rewrite (N, New_Copy (N));
- if not Is_Floating_Point_Type (T) then
- Set_Realval
- (N, Corresponding_Integer_Value (N) * Small_Value (T));
-
- elsif not UR_Is_Zero (Realval (N)) then
+ if Is_Floating_Point_Type (T) then
Set_Realval (N, Machine_Number (Base_Type (T), Realval (N), N));
Set_Is_Machine_Number (N);
+ else
+ Set_Realval (N, Corresponding_Integer_Value (N) * Small_Value (T));
end if;
end if;
--
2.43.0