https://gcc.gnu.org/g:6b23686af726cba55d1ec07748e4ba0324cf2930

commit r15-6152-g6b23686af726cba55d1ec07748e4ba0324cf2930
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Wed Nov 20 16:32:38 2024 +0100

    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:
---
 gcc/ada/sem_ch5.adb | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

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);

Reply via email to