public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Allow calls to Number_Formals when no formals are present
@ 2023-07-28  7:30 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-07-28  7:30 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

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(-)

diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index dad3a654743..7fe517124d9 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -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
diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads
index fee771c20f4..20ca470d7ac 100644
--- a/gcc/ada/einfo-utils.ads
+++ b/gcc/ada/einfo-utils.ads
@@ -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;
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index b356b76f0de..d7690d9f88a 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -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
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 585c0f33d8b..7cd0800a56c 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -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
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-28  7:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28  7:30 [COMMITTED] ada: Allow calls to Number_Formals when no formals are present Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).