aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch6.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2009-04-10 14:03:49 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-10 16:03:49 +0200
commit5334d18ffa2ee58b84200c3df55723963b065dd7 (patch)
tree1a70b39918d3ed7340fb6e3fd20058de32aef1eb /gcc/ada/exp_ch6.adb
parent701b7fbbffdff1ebfe06bc014257e3e18abc93ef (diff)
downloadgcc-5334d18ffa2ee58b84200c3df55723963b065dd7.zip
gcc-5334d18ffa2ee58b84200c3df55723963b065dd7.tar.gz
gcc-5334d18ffa2ee58b84200c3df55723963b065dd7.tar.bz2
exp_ch5.adb, [...]: Move the code that creates a call to the _Postconditions procedure in the case...
2009-04-10 Bob Duff <duff@adacore.com> * exp_ch5.adb, exp_ch6.adb, sem_ch6.adb: Move the code that creates a call to the _Postconditions procedure in the case of implicit returns from analysis to expansion. This eliminates some duplicated code. Use the Postcondition_Proc to find the identity of this procedure during expansion. From-SVN: r145906
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r--gcc/ada/exp_ch6.adb32
1 files changed, 29 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 19c90ad..045bd04 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -4080,7 +4080,34 @@ package body Exp_Ch6 is
Loc := Sloc (Last_Stm);
end if;
- Append_To (S, Make_Simple_Return_Statement (Loc));
+ declare
+ Rtn : constant Node_Id := Make_Simple_Return_Statement (Loc);
+
+ begin
+ -- Append return statement, and set analyzed manually. We
+ -- can't call Analyze on this return since the scope is wrong.
+
+ -- Note: it almost works to push the scope and then do the
+ -- analyze call, but something goes wrong in some weird cases
+ -- and it is not worth worrying about ???
+
+ Append_To (S, Rtn);
+ Set_Analyzed (Rtn);
+
+ -- Call _Postconditions procedure if appropriate. We need to
+ -- do this explicitly because we did not analyze the generated
+ -- return statement above, so the call did not get inserted.
+
+ if Ekind (Spec_Id) = E_Procedure
+ and then Has_Postconditions (Spec_Id)
+ then
+ pragma Assert (Present (Postcondition_Proc (Spec_Id)));
+ Insert_Action (Rtn,
+ Make_Procedure_Call_Statement (Loc,
+ Name =>
+ New_Reference_To (Postcondition_Proc (Spec_Id), Loc)));
+ end if;
+ end;
end if;
end Add_Return;
@@ -4282,8 +4309,7 @@ package body Exp_Ch6 is
end;
-- For a procedure, we add a return for all possible syntactic ends
- -- of the subprogram. Note that reanalysis is not necessary in this
- -- case since it would require a lot of work and accomplish nothing.
+ -- of the subprogram.
if Ekind (Spec_Id) = E_Procedure
or else Ekind (Spec_Id) = E_Generic_Procedure