]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Allow calls to Number_Formals when no formals are present
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 16 Jun 2023 07:16:19 +0000 (09:16 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 28 Jul 2023 07:28:13 +0000 (09:28 +0200)
It is much simpler and safer for the routine Number_Formals to accept
subprogram entities that have no formals.

gcc/ada/

* einfo-utils.adb (Number_Formals): Change types in body.
* einfo-utils.ads (Number_Formals): Change type in spec.
* einfo.ads (Number_Formals): Change type in comment.
* sem_ch13.adb (Is_Property_Function): Fix style in a caller of
Number_Formals that was likely to crash because of missing guards.

gcc/ada/einfo-utils.adb
gcc/ada/einfo-utils.ads
gcc/ada/einfo.ads
gcc/ada/sem_ch13.adb

index dad3a654743b8efe750f31a66c180cede19ec3ba..7fe517124d9e7ac00263c9ba39b2271e485860a5 100644 (file)
@@ -2105,8 +2105,8 @@ package body Einfo.Utils is
    -- Number_Formals --
    --------------------
 
-   function Number_Formals (Id : E) return Pos is
-      N      : Int;
+   function Number_Formals (Id : E) return Nat is
+      N      : Nat;
       Formal : Entity_Id;
 
    begin
index fee771c20f43def388e63e973ab2a6e4be3b3480..20ca470d7acbdc8bea62f25c2c4b0b45de9bd76d 100644 (file)
@@ -227,7 +227,7 @@ package Einfo.Utils is
    function Next_Stored_Discriminant (Id : E) return Entity_Id;
    function Number_Dimensions (Id : E) return Pos;
    function Number_Entries (Id : E) return Nat;
-   function Number_Formals (Id : E) return Pos;
+   function Number_Formals (Id : E) return Nat;
    function Object_Size_Clause (Id : E) return Node_Id;
    function Parameter_Mode (Id : E) return Formal_Kind;
    function Partial_Refinement_Constituents (Id : E) return L;
index b356b76f0de697798cceb16aee31bb00431b80bd..d7690d9f88ab7288ca1ce8145baa711cbe353bd0 100644 (file)
@@ -3832,7 +3832,7 @@ package Einfo is
 
 --    Number_Formals (synthesized)
 --       Applies to subprograms and subprogram types. Yields the number of
---       formals as a value of type Pos.
+--       formals as a value of type Nat.
 
 --    Object_Size_Clause (synthesized)
 --       Applies to entities for types and subtypes. If an object size clause
index 585c0f33d8bcfd939324cecd66815939fe51815e..7cd0800a56cc359c74bcc06dc20a7afc66507b56 100644 (file)
@@ -16544,7 +16544,11 @@ package body Sem_Ch13 is
             It : Interp;
 
             function Is_Property_Function (E : Entity_Id) return Boolean;
-            --  Implements RM 7.3.4 definition of "property function".
+            --  Implements RM 7.3.4 definition of "property function"
+
+            --------------------------
+            -- Is_Property_Function --
+            --------------------------
 
             function Is_Property_Function (E : Entity_Id) return Boolean is
             begin