diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-13 10:25:50 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-13 10:25:50 +0000 |
commit | 614d9f2814af49fecd377f152c761dc9982d065a (patch) | |
tree | 21f162f9ce7b625ec950f58e55711ef6c7f94898 /gcc/ada | |
parent | 7985fb9d646fd6055628289c26e20bd20488ab49 (diff) | |
download | gcc-614d9f2814af49fecd377f152c761dc9982d065a.tar.gz |
2007-12-06 Gary Dismukes <dismukes@adacore.com>
* exp_ch8.ads, exp_ch8.adb (Expand_N_Subprogram_Renaming_Declaration):
In the case where the renamed subprogram is a dereference, call
Force_Evaluation on the prefix.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130833 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/exp_ch8.adb | 34 | ||||
-rw-r--r-- | gcc/ada/exp_ch8.ads | 1 |
2 files changed, 29 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb index a8693c76edf..68fa50eb6e5 100644 --- a/gcc/ada/exp_ch8.adb +++ b/gcc/ada/exp_ch8.adb @@ -131,9 +131,7 @@ package body Exp_Ch8 is -- the prefix, which is itself a name, recursively, and then force -- the evaluation of all the subscripts (or attribute expressions). - elsif K = N_Indexed_Component - or else K = N_Attribute_Reference - then + elsif Nkind_In (K, N_Indexed_Component, N_Attribute_Reference) then Evaluate_Name (Prefix (Fname)); E := First (Expressions (Fname)); @@ -203,9 +201,7 @@ package body Exp_Ch8 is function Evaluation_Required (Nam : Node_Id) return Boolean is begin - if Nkind (Nam) = N_Indexed_Component - or else Nkind (Nam) = N_Slice - then + if Nkind_In (Nam, N_Indexed_Component, N_Slice) then if Is_Packed (Etype (Prefix (Nam))) then return True; else @@ -337,4 +333,30 @@ package body Exp_Ch8 is end if; end Expand_N_Package_Renaming_Declaration; + ---------------------------------------------- + -- Expand_N_Subprogram_Renaming_Declaration -- + ---------------------------------------------- + + procedure Expand_N_Subprogram_Renaming_Declaration (N : Node_Id) is + Nam : constant Node_Id := Name (N); + + begin + -- When the prefix of the name is a function call, we must force the + -- call to be made by removing side effects from the call, since we + -- must only call the function once. + + if Nkind (Nam) = N_Selected_Component + and then Nkind (Prefix (Nam)) = N_Function_Call + then + Remove_Side_Effects (Prefix (Nam)); + + -- For an explicit dereference, the prefix must be captured to prevent + -- reevaluation on calls through the renaming, which could result in + -- calling the wrong subprogram if the access value were to be changed. + + elsif Nkind (Nam) = N_Explicit_Dereference then + Force_Evaluation (Prefix (Nam)); + end if; + end Expand_N_Subprogram_Renaming_Declaration; + end Exp_Ch8; diff --git a/gcc/ada/exp_ch8.ads b/gcc/ada/exp_ch8.ads index 0c6a26240c5..7df54f3069a 100644 --- a/gcc/ada/exp_ch8.ads +++ b/gcc/ada/exp_ch8.ads @@ -31,4 +31,5 @@ package Exp_Ch8 is procedure Expand_N_Exception_Renaming_Declaration (N : Node_Id); procedure Expand_N_Object_Renaming_Declaration (N : Node_Id); procedure Expand_N_Package_Renaming_Declaration (N : Node_Id); + procedure Expand_N_Subprogram_Renaming_Declaration (N : Node_Id); end Exp_Ch8; |