aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch6.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-10-01 10:49:03 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2012-10-01 10:49:03 +0200
commitd85be3ba3ba37ceb2b08a62f0974cb6883c24637 (patch)
tree2e2bd5262029c501de6388f6b86c7540545107ce /gcc/ada/sem_ch6.adb
parentc5a26133df8575533bc97def6e76bf66bec7f91a (diff)
downloadgcc-d85be3ba3ba37ceb2b08a62f0974cb6883c24637.zip
gcc-d85be3ba3ba37ceb2b08a62f0974cb6883c24637.tar.gz
gcc-d85be3ba3ba37ceb2b08a62f0974cb6883c24637.tar.bz2
[multiple changes]
2012-10-01 Ed Schonberg <schonberg@adacore.com> * exp_ch3.ads (Build_Array_Invariant_Proc): moved to body. * exp_ch3.adb (Build_Array_Invariant_Proc, Build_Record_Invariant_Proc): transform into functions. (Insert_Component_Invariant_Checks): for composite types that have components with specified invariants, build a checking procedure, and make into the invariant procedure of the composite type, or incorporate it into the user- defined invariant procedure if one has been created. * sem_ch3.adb (Array_Type_Declaration): Checking for invariants on the component type is defered to the expander. 2012-10-01 Thomas Quinot <quinot@adacore.com> * xsnamest.adb, namet.h, sem_ch10.adb, s-oscons-tmplt.c, xoscons.adb: Minor reformatting. 2012-10-01 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb (Apply_Parameter_Aliasing_And_Validity_Checks): Do not process subprogram renaminds because a) those cannot have PPC pragmas b) the renamed entity already has the PPCs. (Build_PPC_Pragma): Prepend a PPC pragma for consistency with Process_PPCs. * sem_ch6.adb (Last_Implicit_Declaration): Removed. (Process_PPCs): Insert a post condition body at the start of the declarative region of the related subprogram. This way the body will not freeze anything it shouldn't. From-SVN: r191903
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r--gcc/ada/sem_ch6.adb87
1 files changed, 39 insertions, 48 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 5ace348..8c88d8f 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -11087,6 +11087,9 @@ package body Sem_Ch6 is
-- references to parameters of the inherited subprogram to point to the
-- corresponding parameters of the current subprogram.
+ procedure Insert_Before_First_Source_Declaration (Nod : Node_Id);
+ -- Insert node Nod before the first source declaration of the context
+
function Invariants_Or_Predicates_Present return Boolean;
-- Determines if any invariants or predicates are present for any OUT
-- or IN OUT parameters of the subprogram, or (for a function) if the
@@ -11101,9 +11104,6 @@ package body Sem_Ch6 is
-- that an invariant check is required (for an IN OUT parameter, or
-- the returned value of a function.
- function Last_Implicit_Declaration return Node_Id;
- -- Return the last internally-generated declaration of N
-
-------------
-- Grab_CC --
-------------
@@ -11281,6 +11281,36 @@ package body Sem_Ch6 is
return CP;
end Grab_PPC;
+ --------------------------------------------
+ -- Insert_Before_First_Source_Declaration --
+ --------------------------------------------
+
+ procedure Insert_Before_First_Source_Declaration (Nod : Node_Id) is
+ Decls : constant List_Id := Declarations (N);
+ Decl : Node_Id;
+
+ begin
+ if No (Decls) then
+ Set_Declarations (N, New_List (Nod));
+ else
+ Decl := First (Decls);
+
+ while Present (Decl) loop
+ if Comes_From_Source (Decl) then
+ exit;
+ end if;
+
+ Next (Decl);
+ end loop;
+
+ if No (Decl) then
+ Append_To (Decls, Nod);
+ else
+ Insert_Before (Decl, Nod);
+ end if;
+ end if;
+ end Insert_Before_First_Source_Declaration;
+
--------------------------------------
-- Invariants_Or_Predicates_Present --
--------------------------------------
@@ -11358,50 +11388,6 @@ package body Sem_Ch6 is
end if;
end Is_Public_Subprogram_For;
- -------------------------------
- -- Last_Implicit_Declaration --
- -------------------------------
-
- function Last_Implicit_Declaration return Node_Id is
- Loc : constant Source_Ptr := Sloc (N);
- Decls : List_Id := Declarations (N);
- Decl : Node_Id;
- Succ : Node_Id;
-
- begin
- if No (Decls) then
- Decls := New_List (Make_Null_Statement (Loc));
- Set_Declarations (N, Decls);
-
- elsif Is_Empty_List (Declarations (N)) then
- Append_To (Decls, Make_Null_Statement (Loc));
- end if;
-
- -- Implicit and source declarations may be interspersed. Search for
- -- the last implicit declaration which is either succeeded by a
- -- source construct or is the last node in the declarative list.
-
- Decl := First (Declarations (N));
- while Present (Decl) loop
- Succ := Next (Decl);
-
- -- The current declaration is the last one, do not return Empty
-
- if No (Succ) then
- exit;
-
- -- The successor is a source construct
-
- elsif Comes_From_Source (Succ) then
- exit;
- end if;
-
- Next (Decl);
- end loop;
-
- return Decl;
- end Last_Implicit_Declaration;
-
-- Start of processing for Process_PPCs
begin
@@ -11807,7 +11793,12 @@ package body Sem_Ch6 is
-- The entity for the _Postconditions procedure
begin
- Insert_After (Last_Implicit_Declaration,
+ -- Insert the corresponding body of a post condition pragma before
+ -- the first source declaration of the context. This ensures that
+ -- any [sub]types generated in relation to the formals of the
+ -- subprogram are still visible in the _postcondition body.
+
+ Insert_Before_First_Source_Declaration (
Make_Subprogram_Body (Loc,
Specification =>
Make_Procedure_Specification (Loc,