From 5334d18ffa2ee58b84200c3df55723963b065dd7 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Fri, 10 Apr 2009 14:03:49 +0000 Subject: exp_ch5.adb, [...]: Move the code that creates a call to the _Postconditions procedure in the case... 2009-04-10 Bob Duff * 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 --- gcc/ada/exp_ch6.adb | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'gcc/ada/exp_ch6.adb') 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 -- cgit v1.1