]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: No extra formals on anonymous access types of C subprograms
authorJavier Miranda <miranda@adacore.com>
Tue, 11 Nov 2025 19:00:22 +0000 (19:00 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 21 Nov 2025 08:29:37 +0000 (09:29 +0100)
Extra formals must not be added to anonymous access to subprogram
types defined in the profile of imported C subprograms.

gcc/ada/ChangeLog:

* sem_ch6.adb (Create_Extra_Formals): Do not add extra formals to
anonymous access to subprogram types defined in the profile of
subprograms that have foreign convention.

gcc/ada/sem_ch6.adb

index 0629dda91a91b7915a6e4650173f04f4823c76cd..1235ea453b6a99b95438f6b8049dc5ce34d0f0d7 100644 (file)
@@ -9077,6 +9077,17 @@ package body Sem_Ch6 is
       then
          Freeze_Extra_Formals (E);
          return;
+
+      elsif Ekind (Ref_E) in E_Subprogram_Type
+        and then Is_Itype (Ref_E)
+        and then Nkind (Associated_Node_For_Itype (Ref_E)) in
+                   N_Function_Specification
+                 | N_Procedure_Specification
+        and then Has_Foreign_Convention
+                   (Defining_Entity (Associated_Node_For_Itype (Ref_E)))
+      then
+         Freeze_Extra_Formals (E);
+         return;
       end if;
 
       --  If the subprogram is a predefined dispatching subprogram then don't