aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-07-30 12:52:14 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-08-23 10:51:03 +0200
commitf67d108dbcd499cd6db6cb59484c400301e4ebd9 (patch)
tree42397d96b2dcb84cc7f3ffbc515f72a2295110b1 /gcc
parent8719b1843bc0f24a79433c8685d09cf822af0db7 (diff)
downloadgcc-f67d108dbcd499cd6db6cb59484c400301e4ebd9.zip
gcc-f67d108dbcd499cd6db6cb59484c400301e4ebd9.tar.gz
gcc-f67d108dbcd499cd6db6cb59484c400301e4ebd9.tar.bz2
ada: Simplify validity checks for scalar parameters
Replace low-level iteration over formal and actual parameters with a call to high-level Find_Actual routine. Code cleanup; behavior is unaffected. gcc/ada/ * checks.adb (Ensure_Valid): Use Find_Actual.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/checks.adb58
1 files changed, 8 insertions, 50 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 343f027..d13e7bb 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -6799,60 +6799,18 @@ package body Checks is
if Is_Scalar_Type (Typ) then
declare
- P : Node_Id;
- N : Node_Id;
- E : Entity_Id;
- F : Entity_Id;
- A : Node_Id;
- L : List_Id;
+ Formal : Entity_Id;
+ Call : Node_Id;
begin
- -- Find actual argument (which may be a parameter association)
- -- and the parent of the actual argument (the call statement)
+ Find_Actual (Expr, Formal, Call);
- N := Expr;
- P := Parent (Expr);
-
- if Nkind (P) = N_Parameter_Association then
- N := P;
- P := Parent (N);
- end if;
-
- -- If this is an indirect or dispatching call, get signature
- -- from the subprogram type.
-
- if Nkind (P) in N_Entry_Call_Statement
- | N_Function_Call
- | N_Procedure_Call_Statement
+ if Present (Formal)
+ and then
+ (Ekind (Formal) = E_Out_Parameter
+ or else Mechanism (Formal) = By_Reference)
then
- E := Get_Called_Entity (P);
- L := Parameter_Associations (P);
-
- -- Only need to worry if there are indeed actuals, and if
- -- this could be a subprogram call, otherwise we cannot get
- -- a match (either we are not an argument, or the mode of
- -- the formal is not OUT). This test also filters out the
- -- generic case.
-
- if Is_Non_Empty_List (L) and then Is_Subprogram (E) then
-
- -- This is the loop through parameters, looking for an
- -- OUT parameter for which we are the argument.
-
- F := First_Formal (E);
- A := First_Actual (P);
- while Present (F) loop
- if A = N
- and then (Ekind (F) = E_Out_Parameter
- or else Mechanism (F) = By_Reference)
- then
- return;
- end if;
-
- Next_Formal (F);
- Next_Actual (A);
- end loop;
- end if;
+ return;
end if;
end;
end if;