diff options
author | Javier Miranda <miranda@adacore.com> | 2020-03-03 14:27:18 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-10 09:34:58 -0400 |
commit | 4322f3d99b7e5875de59c04939c4a4def1ffde5c (patch) | |
tree | d7c21b2ebb813495d78fc1429ff7667471777f31 | |
parent | dc419b9f8d6f998186706aa1afa50db1ca7efae5 (diff) | |
download | gcc-4322f3d99b7e5875de59c04939c4a4def1ffde5c.zip gcc-4322f3d99b7e5875de59c04939c4a4def1ffde5c.tar.gz gcc-4322f3d99b7e5875de59c04939c4a4def1ffde5c.tar.bz2 |
[Ada] Classwide controlled obj not dispatching
2020-06-10 Javier Miranda <miranda@adacore.com>
gcc/ada/
* sem_ch3.adb (Analyze_Declarations): Adjust the machinery that
takes care of late body overriding of initialize, adjust,
finalize. Remove ASIS mode code.
-rw-r--r-- | gcc/ada/sem_ch3.adb | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 83393c8..4cddbbe 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2592,12 +2592,10 @@ package body Sem_Ch3 is -- Local variables Context : Node_Id := Empty; + Ctrl_Typ : Entity_Id := Empty; Freeze_From : Entity_Id := Empty; Next_Decl : Node_Id; - Body_Seen : Boolean := False; - -- Flag set when the first body [stub] is encountered - -- Start of processing for Analyze_Declarations begin @@ -2613,6 +2611,16 @@ package body Sem_Ch3 is Freeze_From := First_Entity (Current_Scope); end if; + -- Remember if the declaration we just processed is the full type + -- declaration of a controlled type (to handle late overriding of + -- initialize, adjust or finalize). + + if Nkind (Decl) = N_Full_Type_Declaration + and then Is_Controlled (Defining_Identifier (Decl)) + then + Ctrl_Typ := Defining_Identifier (Decl); + end if; + -- At the end of a declarative part, freeze remaining entities -- declared in it. The end of the visible declarations of package -- specification is not the end of a declarative part if private @@ -2758,19 +2766,17 @@ package body Sem_Ch3 is -- ??? A cleaner approach may be possible and/or this solution -- could be extended to general-purpose late primitives, TBD. - if not Body_Seen and then not Is_Body (Decl) then - Body_Seen := True; + if Present (Ctrl_Typ) then - if Nkind (Next_Decl) = N_Subprogram_Body then - Handle_Late_Controlled_Primitive (Next_Decl); - end if; + -- No need to continue searching for late body overriding if + -- the controlled type is already frozen. - else - -- In ASIS mode, if the next declaration is a body, complete - -- the analysis of declarations so far. - -- Is this still needed??? + if Is_Frozen (Ctrl_Typ) then + Ctrl_Typ := Empty; - Resolve_Aspects; + elsif Nkind (Next_Decl) = N_Subprogram_Body then + Handle_Late_Controlled_Primitive (Next_Decl); + end if; end if; Adjust_Decl; |