From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [COMMITTED] ada: Allow calls to Number_Formals when no formals are present
Date: Fri, 28 Jul 2023 09:30:42 +0200 [thread overview]
Message-ID: <20230728073042.1852207-1-poulhies@adacore.com> (raw)
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
reply other threads:[~2023-07-28 7:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230728073042.1852207-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).