summaryrefslogtreecommitdiff
path: root/gcc/ada/checks.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-01 08:45:43 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-01 08:45:43 +0000
commit7c443ae867c76ab419c538f6c51523e210653812 (patch)
treebc41eca22e0a81ac94816a7d59b5d89a6242b070 /gcc/ada/checks.adb
parent5d3fb9475a7b40c592e6caabe1d271e5d068ebd6 (diff)
downloadgcc-7c443ae867c76ab419c538f6c51523e210653812.tar.gz
2012-10-01 Robert Dewar <dewar@adacore.com>
* freeze.adb, sem_ch6.adb, opt.ads, sem_ch13.adb, exp_ch3.adb: Minor reformatting. 2012-10-01 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb (Build_PPC_Pragma): A PPC pragma can now be properly associated with a subprogram body. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191902 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/checks.adb')
-rw-r--r--gcc/ada/checks.adb41
1 files changed, 33 insertions, 8 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 885a5686c60..8d40abcb06e 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -1876,8 +1876,9 @@ package body Checks is
----------------------
procedure Build_PPC_Pragma (PPC_Nam : Name_Id; Check : Node_Id) is
- Loc : constant Source_Ptr := Sloc (Subp);
- Prag : Node_Id;
+ Loc : constant Source_Ptr := Sloc (Subp);
+ Decls : List_Id;
+ Prag : Node_Id;
begin
Prag :=
@@ -1904,11 +1905,34 @@ package body Checks is
if Nkind (Parent (Subp_Decl)) = N_Compilation_Unit then
Add_Global_Declaration (Prag);
+ Analyze (Prag);
+
+ -- PPC pragmas associated with subprogram bodies must be inserted in
+ -- the declarative part of the body.
+
+ elsif Nkind (Subp_Decl) = N_Subprogram_Body then
+ Decls := Declarations (Subp_Decl);
+
+ if No (Decls) then
+ Decls := New_List;
+ Set_Declarations (Subp_Decl, Decls);
+ end if;
+
+ Append_To (Decls, Prag);
+
+ -- Ensure the proper visibility of the subprogram body and its
+ -- parameters.
+
+ Push_Scope (Subp);
+ Analyze (Prag);
+ Pop_Scope;
+
+ -- For subprogram declarations insert the PPC pragma right after the
+ -- declarative node.
+
else
- Insert_After (Subp_Decl, Prag);
+ Insert_After_And_Analyze (Subp_Decl, Prag);
end if;
-
- Analyze (Prag);
end Build_PPC_Pragma;
-- Local variables
@@ -1941,10 +1965,11 @@ package body Checks is
or else Is_Imported (Subp)
or else Is_Intrinsic_Subprogram (Subp)
- -- Do not consider subprogram bodies because pre and post conditions
- -- cannot be associated with them.
+ -- The PPC pragmas generated by this routine do not correspond to
+ -- source aspects, therefore they cannot be applied to abstract
+ -- subprograms.
- or else Nkind (Subp_Decl) /= N_Subprogram_Declaration
+ or else Nkind (Subp_Decl) = N_Abstract_Subprogram_Declaration
-- Do not process null procedures because there is no benefit of
-- adding the checks to a no action routine.