]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Refactor warning about null loops
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 20 Nov 2024 15:32:38 +0000 (16:32 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:58:00 +0000 (10:58 +0100)
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.

gcc/ada/sem_ch5.adb

index 4c82e274ddb8719c721433569bd50adb5b7da529..2a5c8dcdbe52bc3a7f77a3c559787bf2367638c8 100644 (file)
@@ -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);