GNAT implements Machine_Rounding as an alias for Rounding but, whereas the implementation of the latter is in line when possible, that of the former is always out of line, which is not aligned with the intent of the Ada RM.
This changes the compiler to using for Machine_Rounding the same in line implementation as Rounding when possible.
Running these commands:
gcc -c f.adb -gnatD grep system f.adb.dg
On the following sources:
function F (Val : Float) return Integer is begin return Integer (Float'Machine_Rounding (Val)); end;
Should execute silently.
2019-09-19 Eric Botcazou
- exp_attr.adb (Is_Inline_Floating_Point_Attribute): Treat Machine_Rounding as an alias for Rounding.
- sem_res.adb (Simplify_Type_Conversion): Likewise.
d6c801510a1 [Ada] Implement Machine_Rounding attribute in line when possible
gcc/ada/ChangeLog | 6 ++++++
gcc/ada/exp_attr.adb | 12 ++++++------
gcc/ada/sem_res.adb | 4 +++-
3 files changed, 15 insertions(+), 7 deletions(-)