aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2023-03-29 16:41:44 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-05-29 10:23:19 +0200
commit204ecf39ca639cf77de1cc4a510a369fa2f91798 (patch)
tree9d5bf360204cb98731845b18a9f90508e64ddb12
parenta17e01a6ce3956d79454047bfe4a3a405e89be7f (diff)
downloadgcc-204ecf39ca639cf77de1cc4a510a369fa2f91798.zip
gcc-204ecf39ca639cf77de1cc4a510a369fa2f91798.tar.gz
gcc-204ecf39ca639cf77de1cc4a510a369fa2f91798.tar.bz2
ada: Reuse routine for getting from body entity to spec entity
Cleanup related to handling of access-to-subprogram types with Pre and Post aspects. Behavior is unaffected. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Replace low-level navigation with a high-level Unique_Entity.
-rw-r--r--gcc/ada/sem_util.adb22
1 files changed, 1 insertions, 21 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index d71329b..64abfb1 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -4546,13 +4546,12 @@ package body Sem_Util is
-- Local variables
Items : constant Node_Id := Contract (Subp_Id);
- Subp_Decl : constant Node_Id := Unit_Declaration_Node (Subp_Id);
Case_Prag : Node_Id := Empty;
Post_Prag : Node_Id := Empty;
Prag : Node_Id;
Seen_In_Case : Boolean := False;
Seen_In_Post : Boolean := False;
- Spec_Id : Entity_Id;
+ Spec_Id : constant Entity_Id := Unique_Entity (Subp_Id);
-- Start of processing for Check_Result_And_Post_State
@@ -4570,25 +4569,6 @@ package body Sem_Util is
return;
end if;
- -- Retrieve the entity of the subprogram spec (if any)
-
- if Nkind (Subp_Decl) = N_Subprogram_Body
- and then Present (Corresponding_Spec (Subp_Decl))
- then
- Spec_Id := Corresponding_Spec (Subp_Decl);
-
- elsif Nkind (Subp_Decl) = N_Subprogram_Body_Stub
- and then Present (Corresponding_Spec_Of_Stub (Subp_Decl))
- then
- Spec_Id := Corresponding_Spec_Of_Stub (Subp_Decl);
-
- elsif Nkind (Subp_Decl) = N_Entry_Body then
- Spec_Id := Corresponding_Spec (Subp_Decl);
-
- else
- Spec_Id := Subp_Id;
- end if;
-
-- Examine all postconditions for attribute 'Result and a post-state
Prag := Pre_Post_Conditions (Items);