aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch7.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-01 15:50:27 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-01 15:50:27 +0200
commit6a2e4f0bc7db748ff765e354db134ebc83899c03 (patch)
treea7d2b704c6cfee31f7ae6725114600c4d9337e92 /gcc/ada/exp_ch7.adb
parent5fcafa6051863dbabf1d9798ec45b83df942509d (diff)
downloadgcc-6a2e4f0bc7db748ff765e354db134ebc83899c03.zip
gcc-6a2e4f0bc7db748ff765e354db134ebc83899c03.tar.gz
gcc-6a2e4f0bc7db748ff765e354db134ebc83899c03.tar.bz2
[multiple changes]
2011-08-01 Robert Dewar <dewar@adacore.com> * make.adb, sem_ch4.adb: Minor reformatting. * gcc-interface/Make-lang.in: Update dependencies. * sem_util.adb, exp_ch5.adb: Minor reformatting. 2011-08-01 Arnaud Charlet <charlet@adacore.com> * gnat_rm.texi: Fix definition of Long_Integer. 2011-08-01 Ed Schonberg <schonberg@adacore.com> * exp_aggr.adb: check limit size of static aggregate unconditionally, to prevent storage exhaustion. * exp_ch7.adb (Clean_Simple_Protected_Objects): if the scope being finalized is a function body, insert the cleanup code before the final return statement, to prevent spurious warnings. * s-pooglo.ads: add overriding indicator. From-SVN: r177035
Diffstat (limited to 'gcc/ada/exp_ch7.adb')
-rw-r--r--gcc/ada/exp_ch7.adb16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index ebfac59..b6b8c85 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -729,15 +729,25 @@ package body Exp_Ch7 is
Ref : constant Node_Id := New_Occurrence_Of (E, Sloc (Stmt));
begin
+ -- If the current context is a function, the end of the
+ -- statement sequence is likely to be a return statement.
+ -- The cleanup code must be executed before the return.
+
+ if Ekind (Current_Scope) = E_Function
+ and then Nkind (Stmt) = Sinfo.N_Return_Statement
+ then
+ Stmt := Prev (Stmt);
+ end if;
+
if Is_Simple_Protected_Type (Typ) then
- Append_To (Stmts, Cleanup_Protected_Object (N, Ref));
+ Insert_After (Stmt, Cleanup_Protected_Object (N, Ref));
elsif Has_Simple_Protected_Object (Typ) then
if Is_Record_Type (Typ) then
- Append_List_To (Stmts, Cleanup_Record (N, Ref, Typ));
+ Insert_List_After (Stmt, Cleanup_Record (N, Ref, Typ));
elsif Is_Array_Type (Typ) then
- Append_List_To (Stmts, Cleanup_Array (N, Ref, Typ));
+ Insert_List_After (Stmt, Cleanup_Array (N, Ref, Typ));
end if;
end if;
end;