From: Piotr Trojanek Date: Mon, 24 Feb 2025 09:40:16 +0000 (+0100) Subject: ada: Simplify tests for positive rational numbers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45a305c3c7b431c5be761dd7e05cc99384b32b32;p=thirdparty%2Fgcc.git ada: Simplify tests for positive rational numbers 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. --- diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 5e7cba8bef9..76a8c0ba733 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index b94606eabc7..4090d0c7117 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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