Skip to content
Snippets Groups Projects
Commit 9f857be3 authored by Gary Dismukes's avatar Gary Dismukes Committed by Pierre-Marie de Rodat
Browse files

[Ada] Add support for defaulted Storage_Model_Type aspect and subaspects

The compiler currently rejects a Storage_Model_Type aspect that is not
specified with an aggregate, or that has an aggregate that does not
specify all defined "subaspects" (Address_Type, Null_Address, Allocate,
etc.). The RFC for this feature defines the aspect to fully default to
the native memory model when no aggregate is given, and also allows any
subaspects to be specified and others to default in the case where the
address type is the native address type (System.Address), whether that
address type is explicitly specified or defaulted. This set of changes
now supports that defaulting semantics. Note that the subaspect
retrieval functions in Sem_Util.Storage_Model_Support (which are called
by the compiler back ends) will now return Empty for any subprogram
subaspects (Allocate, Deallocate, etc.) that are defaulted in the aspect
(that is, in the native model case where the address type is
System.Address).  Also in the native case, retrieval of defaulted
subaspects Address_Type and Null_Address will return the entities for
System.Address and System.Null_Address, respectively. Additionally,
error checks for multiple associations given for the same subaspect are
now done.

gcc/ada/

	* aspects.ads (Aspect_Argument): Change the association for
	Aspect_Storage_Model_Type from Expression to
	Optional_Expression.
	* exp_util.ads (Find_Storage_Op): Update comment to indicate
	that Empty can be returned in the case where a storage-model
	operation is defaulted.
	* exp_util.adb (Find_Storage_Op): Allow the function to return
	Empty in Storage_Model_Type case rather than raising
	Program_Error, so that Procedure_To_Call fields in N_Allocator
	and N_Free_Statement nodes will be set to Empty in the defaulted
	native storage-model case.
	* sem_ch13.adb: Add with and use of System.Case_Util (and
	reformat context_clause).
	(Check_Aspect_At_Freeze_Point): Return with no action for a
	Storage_Model_Type aspect with no expression (fully-defaulted
	native memory-model case).
	(Resolve_Storage_Model_Type_Argument): If an Address_Type has
	not been explicitly specified, then set Addr_Type to denote type
	System.Address.
	(Validate_Storage_Model_Type_Aspect): Return immediately in the
	case where the aspect has no Expression (fully-defaulted native
	memory-model case).  No longer issue an error when Address_Type
	isn't specified, and instead use type System.Address as the
	default address type. When the address type is
	System.Address (whether specified or defaulted), no longer issue
	errors for any other "subaspects" that aren't specified, since
	in that case those are allowed to default as well. Remove ???
	comment about needing to check for duplicates, which is now
	addressed.
	(Check_And_Resolve_Storage_Model_Type_Argument): New procedure
	to check that an association for a storage-model subaspect in
	the aggregate has not been specified earlier in the aggregate,
	and to then resolve the expression of the association and save
	the resolved entity. Called by
	Validate_Storage_Model_Type_Aspect.
	* sem_util.ads (Storage_Model_Support): Update comments on specs
	of the functions Get_Storage_Model_Type_Entity,
	Storage_Model_Address_Type, and Storage_Model_Null_Address to
	indicate the behavior when the address type is System.Address
	(the native memory-model case).
	* sem_util.adb
	(Storage_Model_Support.Get_Storage_Model_Type_Entity): Suppress
	the search for the given subaspect name (Nam) when the
	Storage_Model_Type aspect is fully defaulted (i.e., no
	Expression is present) and simply return. In cases where the
	search is done, but no association that matches Nam is found,
	return System.Address for the Name_Address_Type case, return
	System.Null_Address for the Name_Null_Address case, and return
	Empty for all other cases.
parent 6beeff02
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment