From: Piotr Trojanek Date: Wed, 20 Nov 2024 15:32:38 +0000 (+0100) Subject: ada: Refactor warning about null loops X-Git-Tag: basepoints/gcc-16~3401 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b23686af726cba55d1ec07748e4ba0324cf2930;p=thirdparty%2Fgcc.git ada: Refactor warning about null loops Code cleanup; semantics is unaffected. gcc/ada/ChangeLog: * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Move call to Comes_From_Source to the outer if-statement. --- diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 4c82e274ddb8..2a5c8dcdbe52 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3314,24 +3314,25 @@ package body Sem_Ch5 is -- instance, since in practice they tend to be dubious in these -- cases since they can result from intended parameterization. - if not Inside_A_Generic and then not In_Instance then + if Comes_From_Source (N) + and then not Inside_A_Generic + and then not In_Instance + then -- Specialize msg if invalid values could make the loop -- non-null after all. if Null_Range then - if Comes_From_Source (N) then - Error_Msg_N - ("??loop range is null, loop will not execute", DS); - end if; + Error_Msg_N + ("??loop range is null, loop will not execute", DS); -- Here is where the loop could execute because of -- invalid values, so issue appropriate message. - elsif Comes_From_Source (N) then + else Error_Msg_N - ("??loop range may be null, loop may not execute", - DS); + ("??loop range may be null, loop may not execute", DS); + Error_Msg_N ("??can only execute if invalid values are present", DS);