]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify tests for positive rational numbers
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 24 Feb 2025 09:40:16 +0000 (10:40 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 6 Jun 2025 08:37:15 +0000 (10:37 +0200)
Checking a rational number for being positive takes a shorter code path than
a general comparison with zero. Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Tune code for
attribute Small.
* sem_prag.adb (Analyze_Attribute): Tune code for pragma Time_Slice.

gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb

index 5e7cba8bef91b4e3cfd2d484f255c823169b4b27..76a8c0ba7331579f1e8c488815399ebe51497732 100644 (file)
@@ -7250,7 +7250,7 @@ package body Sem_Ch13 is
             else
                Small := Expr_Value_R (Expr);
 
-               if Small <= Ureal_0 then
+               if not UR_Is_Positive (Small) then
                   Error_Msg_N ("small value must be greater than zero", Expr);
                   return;
                end if;
index b94606eabc71db41108e07e64bfd11bbcc788fe1..4090d0c71175897c6f6e0d46ce2667715ea45aa4 100644 (file)
@@ -26953,7 +26953,7 @@ package body Sem_Prag is
                Opt.Time_Slice_Set := True;
                Val := Expr_Value_R (Get_Pragma_Arg (Arg1));
 
-               if Val <= Ureal_0 then
+               if not UR_Is_Positive (Val) then
                   Opt.Time_Slice_Value := 0;
 
                elsif Val > UR_From_Uint (UI_From_Int (1000)) then