diff options
author | squirek <squirek@adacore.com> | 2024-08-13 12:06:52 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-11-12 14:00:49 +0100 |
commit | 9bba882f922e69abc72fa71520be649258cfd856 (patch) | |
tree | 67bf21646c49e0db7da8f139680ebddc45d73e44 /gcc | |
parent | 300557bd6d0145cb0210942d80f866cc3b057695 (diff) | |
download | gcc-9bba882f922e69abc72fa71520be649258cfd856.zip gcc-9bba882f922e69abc72fa71520be649258cfd856.tar.gz gcc-9bba882f922e69abc72fa71520be649258cfd856.tar.bz2 |
ada: Spurious error on abstract primitive with access formals
This patch fixes an issue in the compiler whereby using anonymous access
types as abstract overridden subprogram formals for a derived abtract type
may lead to compile-time errors.
gcc/ada/ChangeLog:
* accessibility.adb (Type_Access_Level): Add handling for
subprogram aliases.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/accessibility.adb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index 2981033..a412981 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -2331,7 +2331,20 @@ package body Accessibility is return Scope_Depth (Standard_Standard); end if; - return Scope_Depth (Enclosing_Dynamic_Scope (Btyp)); + -- It is possible that the current scope is an aliased subprogram - + -- this can happen when an abstract primitive from a root type is not + -- not visible. + + if Is_Subprogram (Enclosing_Dynamic_Scope (Btyp)) + and then Present (Alias (Enclosing_Dynamic_Scope (Btyp))) + then + return Scope_Depth (Ultimate_Alias (Enclosing_Dynamic_Scope (Btyp))); + + -- Otherwise, simply use the enclosing dynamic scope + + else + return Scope_Depth (Enclosing_Dynamic_Scope (Btyp)); + end if; end Type_Access_Level; end Accessibility; |