diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-07-07 15:20:30 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2016-07-07 15:20:30 +0200 |
commit | 86ec3bfb9fc3729d1e17d750e2d76be03f4f7110 (patch) | |
tree | 5f9cb4cf824f99f62768c9f881adcfe0418ff120 /gcc/ada/exp_ch6.adb | |
parent | 0640c7d139ea91870c378de96cab14d708517593 (diff) | |
download | gcc-86ec3bfb9fc3729d1e17d750e2d76be03f4f7110.zip gcc-86ec3bfb9fc3729d1e17d750e2d76be03f4f7110.tar.gz gcc-86ec3bfb9fc3729d1e17d750e2d76be03f4f7110.tar.bz2 |
[multiple changes]
2016-07-07 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Expand_Internal_Init_Call): Subsidiary procedure
to Expand_Protected_ Subprogram_Call, to handle properly a
call to a protected function that provides the initialization
expression for a private component of the same protected type.
* sem_ch9.adb (Analyze_Protected_Definition): Layout must be
applied to itypes generated for a private operation of a protected
type that has a formal of an anonymous access to subprogram,
because these itypes have no freeze nodes and are frozen in place.
* sem_ch4.adb (Analyze_Selected_Component): If prefix is a
protected type and it is not a current instance, do not examine
the first private component of the type.
2016-07-07 Arnaud Charlet <charlet@adacore.com>
* exp_imgv.adb, g-dynhta.adb, s-regexp.adb, s-fatgen.adb, s-poosiz.adb:
Minor removal of extra whitespace.
* einfo.ads: minor removal of repeated "as" in comment
2016-07-07 Vadim Godunko <godunko@adacore.com>
* adaint.c: Complete previous change.
From-SVN: r238117
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 938484b..a14274c 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5945,6 +5945,12 @@ package body Exp_Ch6 is is Rec : Node_Id; + procedure Expand_Internal_Init_Call; + -- A call to an operation of the type may occur in the initialization + -- of a private component. In that case the prefix of the call is an + -- entity name and the call is treated as internal even though it + -- appears in code outside of the protected type. + procedure Freeze_Called_Function; -- If it is a function call it can appear in elaboration code and -- the called entity must be frozen before the call. This must be @@ -5952,6 +5958,31 @@ package body Exp_Ch6 is -- to something other than a call (e.g. a temporary initialized in a -- transient block). + ------------------------------- + -- Expand_Internal_Init_Call -- + ------------------------------- + + procedure Expand_Internal_Init_Call is + begin + -- If the context is a protected object (rather than a protected + -- type) the call itself is bound to raise program_error because + -- the protected body will not have been elaborated yet. This is + -- diagnosed subsequently in Sem_Elab. + + Freeze_Called_Function; + + -- The target of the internal call is the first formal of the + -- enclosing initialization procedure. + + Rec := New_Occurrence_Of (First_Formal (Current_Scope), Sloc (N)); + Build_Protected_Subprogram_Call (N, + Name => Name (N), + Rec => Rec, + External => False); + Analyze (N); + Resolve (N, Etype (Subp)); + end Expand_Internal_Init_Call; + ---------------------------- -- Freeze_Called_Function -- ---------------------------- @@ -5975,14 +6006,24 @@ package body Exp_Ch6 is -- case this must be handled as an inter-object call. if not In_Open_Scopes (Scop) - or else not Is_Entity_Name (Name (N)) + or else (not Is_Entity_Name (Name (N))) then if Nkind (Name (N)) = N_Selected_Component then Rec := Prefix (Name (N)); - else - pragma Assert (Nkind (Name (N)) = N_Indexed_Component); + elsif Nkind (Name (N)) = N_Indexed_Component then Rec := Prefix (Prefix (Name (N))); + + else + -- If the context is the initialization procedure for a protected + -- type, the call is legal because the called entity must be a + -- function of that enclosing type, and this is treated as an + -- internal call. + + pragma Assert (Is_Entity_Name (Name (N)) + and then Inside_Init_Proc); + Expand_Internal_Init_Call; + return; end if; Freeze_Called_Function; |