[COMMITTED] ada: Allow calls to Number_Formals when no formals are present
Checks
Commit Message
From: Piotr Trojanek <trojanek@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/einfo-utils.adb | 4 ++--
gcc/ada/einfo-utils.ads | 2 +-
gcc/ada/einfo.ads | 2 +-
gcc/ada/sem_ch13.adb | 6 +++++-
4 files changed, 9 insertions(+), 5 deletions(-)
@@ -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
@@ -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;
@@ -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 Nat.
-- Object_Size_Clause (synthesized)
-- Applies to entities for types and subtypes. If an object size clause
@@ -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