diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-13 11:39:38 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-13 11:39:38 +0100 |
commit | 3603fa5cfb32ced1402f31b174a3023826745160 (patch) | |
tree | e6760add6c9c6fce7091b39302201823702914ee /gcc/ada/contracts.adb | |
parent | 3abbc5c2409fae926307f5321debdf6191cd2152 (diff) | |
download | gcc-3603fa5cfb32ced1402f31b174a3023826745160.zip gcc-3603fa5cfb32ced1402f31b174a3023826745160.tar.gz gcc-3603fa5cfb32ced1402f31b174a3023826745160.tar.bz2 |
Code cleanups.
From-SVN: r244412
Diffstat (limited to 'gcc/ada/contracts.adb')
-rw-r--r-- | gcc/ada/contracts.adb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 3a013d9..862e85b 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -1085,8 +1085,10 @@ package body Contracts is -------------------------------- procedure Analyze_Previous_Contracts (Body_Decl : Node_Id) is - Body_Id : constant Entity_Id := Defining_Entity (Body_Decl); - Par : Node_Id; + Body_Id : constant Entity_Id := Defining_Entity (Body_Decl); + Orig_Decl : constant Node_Id := Original_Node (Body_Decl); + + Par : Node_Id; begin -- A body that is in the process of being inlined appears from source, @@ -1109,6 +1111,29 @@ package body Contracts is Freeze_Id => Defining_Entity (Body_Decl)); exit; + + -- Do not look for an enclosing package body when the construct which + -- causes freezing is a body generated for an expression function and + -- it appears within a package spec. This ensures that the traversal + -- will not reach too far up the parent chain and attempt to freeze a + -- package body which should not be frozen. + + -- package body Enclosing_Body + -- with Refined_State => (State => Var) + -- is + -- package Nested is + -- type Some_Type is ...; + -- function Cause_Freezing return ...; + -- private + -- function Cause_Freezing is (...); + -- end Nested; + -- + -- Var : Nested.Some_Type; + + elsif Nkind (Par) = N_Package_Declaration + and then Nkind (Orig_Decl) = N_Expression_Function + then + exit; end if; Par := Parent (Par); |