&& !present_gnu_tree (gnat_entity)
&& In_Extended_Main_Code_Unit (gnat_entity))
{
- /* Ensure that we are in a subprogram mentioned in the Scope chain of
+ /* Unless it's for an anonymous access type, whose scope is irrelevant,
+ ensure that we are in a subprogram mentioned in the Scope chain of
this entity, our current scope is global, or we encountered a task
or entry (where we can't currently accurately check scoping). */
- if (!current_function_decl
+ if (Ekind (gnat_entity) == E_Anonymous_Access_Type
+ || !current_function_decl
|| DECL_ELABORATION_PROC_P (current_function_decl))
{
process_type (gnat_entity);
gnat_result_type = Etype (gnat_node);
}
- /* Expand the type of this identifier first, in case it is an enumeral
- literal, which only get made when the type is expanded. There is no
- order-of-elaboration issue here. */
- gnu_result_type = get_unpadded_type (gnat_result_type);
+ /* Expand the type of this identifier first if it is needed, in case it is an
+ enumeral literal, which only get made when the type is expanded. There is
+ no order-of-elaboration issue here. */
+ if (Is_Subprogram (gnat_entity))
+ gnu_result_type = NULL_TREE;
+ else
+ gnu_result_type = get_unpadded_type (gnat_result_type);
/* If this is a non-imported elementary constant with an address clause,
retrieve the value instead of a pointer to be dereferenced unless