[Ada] Fix inconsistent iteration with First_Formal and Next_Entity

Message ID 20210504095222.GA90494@adacore.com
State New
Headers show
Series
  • [Ada] Fix inconsistent iteration with First_Formal and Next_Entity
Related show

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m.
Iteration routines should come in pairs, i.e. First_Formal with
Next_Formal and First_Entity with Next_Entity. This patch fixes two
occurrences where First_Formal was used with Next_Entity. Cleanup only;
semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_ch12.adb (Check_Abstract_Primitives): Match First_Formal
	with Next_Formal.
	* sem_ch6.adb (Is_Non_Overriding_Operation): Likewise.

Patch

diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -13682,8 +13682,8 @@  package body Sem_Ch12 is
                                     exit;
                                  end if;
 
-                                 Next_Entity (Anc_Formal);
-                                 Next_Entity (Act_Formal);
+                                 Next_Formal (Anc_Formal);
+                                 Next_Formal (Act_Formal);
                               end loop;
 
                               --  If we traversed through all of the formals


diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -10713,8 +10713,8 @@  package body Sem_Ch6 is
                            exit;
                         end if;
 
-                        Next_Entity (P_Formal);
-                        Next_Entity (N_Formal);
+                        Next_Formal (P_Formal);
+                        Next_Formal (N_Formal);
                      end loop;
 
                      --  Found a matching primitive operation belonging to the