[COMMITTED] ada: Simplify detection of controlling formals

Message ID 20221104135721.86383-1-poulhies@adacore.com
State Unresolved
Headers
Series [COMMITTED] ada: Simplify detection of controlling formals |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Marc Poulhiès Nov. 4, 2022, 1:57 p.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

When detecting controlling formals we are only interested in formal
parameters and not in other entities.

gcc/ada/

	* sem_ch6.adb (Controlling_Formal): Iterate with First/Next_Formal
	and not with First/Next_Entity.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch6.adb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 228adcff5cd..d28de10d3d6 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -10711,13 +10711,13 @@  package body Sem_Ch6 is
          E : Entity_Id;
 
       begin
-         E := First_Entity (Prim);
+         E := First_Formal (Prim);
          while Present (E) loop
-            if Is_Formal (E) and then Is_Controlling_Formal (E) then
+            if Is_Controlling_Formal (E) then
                return E;
             end if;
 
-            Next_Entity (E);
+            Next_Formal (E);
          end loop;
 
          return Empty;