diff options
author | Javier Miranda <miranda@adacore.com> | 2023-09-08 11:53:44 +0000 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-09-19 13:26:42 +0200 |
commit | 54c16824f0f05313bfc7df5e625f108b4ff7c636 (patch) | |
tree | 3c3365d211423fddcf5bcea1e0b125433f50cabc /gcc/ada/contracts.adb | |
parent | 564ecb7d5afb0bb4eb39285ce65c631490e37dce (diff) | |
download | gcc-54c16824f0f05313bfc7df5e625f108b4ff7c636.zip gcc-54c16824f0f05313bfc7df5e625f108b4ff7c636.tar.gz gcc-54c16824f0f05313bfc7df5e625f108b4ff7c636.tar.bz2 |
ada: Crash processing type invariants on child subprogram
gcc/ada/
* contracts.adb
(Has_Public_Visibility_Of_Subprogram): Add missing support for
child subprograms.
Diffstat (limited to 'gcc/ada/contracts.adb')
-rw-r--r-- | gcc/ada/contracts.adb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 77578da..4aaa276 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -2484,7 +2484,7 @@ package body Contracts is -- declarations of the package containing the type, or in the -- visible declaration of a child unit of that package. - else + elsif Is_List_Member (Subp_Decl) then declare Decls : constant List_Id := List_Containing (Subp_Decl); @@ -2508,6 +2508,29 @@ package body Contracts is (Specification (Unit_Declaration_Node (Subp_Scope)))); end; + + -- Determine whether the subprogram is a child subprogram of + -- of the package containing the type. + + else + pragma Assert + (Nkind (Parent (Subp_Decl)) = N_Compilation_Unit); + + declare + Subp_Scope : constant Entity_Id := + Scope (Defining_Entity (Subp_Decl)); + Typ_Scope : constant Entity_Id := Scope (Typ); + + begin + return + Ekind (Subp_Scope) = E_Package + and then + (Typ_Scope = Subp_Scope + or else + (Is_Child_Unit (Subp_Scope) + and then Is_Ancestor_Package + (Typ_Scope, Subp_Scope))); + end; end if; end Has_Public_Visibility_Of_Subprogram; |