Hi,
Discovered this error when attempting to allocate from a Root_Storage_Pool_With_Subpools derived type. If the type is derived in the current compilation unit, and Allocate is not overridden on derivation (as is typically the case with Root_Storage_Pool_With_Subpools), the entity for Allocate for the derived type is then an alias to System.Storage_Pools.Subpools.Allocate. When the allocator is built, gnat_to_gnu_entity is called with definition == false for the derived storage pool's allocate operation. An assertion is gnat_to_gnu_entity fails in this case, since it is not a definition, and Is_Public is false. If the storage pool type was instead derived in a different compilation unit, this assertion is not triggered since the aliased entity has the Public property. This patch adds an extra check in the assertion (decl.c: gnat_to_gnu_entity) that the entity has the Aliased property. Also included a comment that describes the special case as per the description above. Bootstrapped and tested on x86_64-unknown-freebsd12.1 with no regressions. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 871a309ab7d..5ea930f4f65 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -447,6 +447,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* If we get here, it means we have not yet done anything with this entity. If we are not defining it, it must be a type or an entity that is defined elsewhere or externally, otherwise we should have defined it already. */ + + /* One exception relates to an entity, typically an inherited operation, + which has an alias pointing to the parent's operation. Often such an + aliased entity will also carry with it the Is_Public property if it was + declared in a separate compilation unit, but when a type is extended + within the current unit, the aliased entity will not pass this + assertion. It is neither defined (since it is an inherited operation, + and is not Public, since it is within the current compilation unit. */ + gcc_assert (definition || is_type || kind == E_Discriminant @@ -454,6 +463,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) || kind == E_Label || (kind == E_Constant && Present (Full_View (gnat_entity))) || Is_Public (gnat_entity) + || Present (Alias (gnat_entity)) || type_annotate_only); /* Get the name of the entity and set up the line number and filename of Thanks, Richard Wai ANNEXI-STRAYLINE