-- For object declarations, the flag is set when an address clause for the
-- object is encountered. Legality checks on the address expression only take
-- place at the freeze point of the object. In Ada 2012, the flag is also set
--- when an address or an alignment aspect for the object is encountered (note
--- the discrepancy with the non-aspect case).
+-- when an address aspect for the object is encountered.
-- Most types have an explicit freeze node, because they cannot be elaborated
-- until all representation and operational items that apply to them have been
Check_Address_Clause (E);
-- Similar processing is needed for aspects that may affect object
- -- layout, like Alignment, if there is an initialization expression.
+ -- layout, like Address, if there is an initialization expression.
-- We don't do this if there is a pragma Linker_Section, because it
-- would prevent the back end from statically initializing the
-- object; we don't want elaboration code in that case.
if A_Id in Boolean_Aspects and then No (Expr) then
Delay_Required := False;
- -- For non-Boolean aspects, don't delay if integer literal,
- -- unless the aspect is Alignment, which affects the
- -- freezing of an initialized object.
+ -- For non-Boolean aspects, don't delay if integer literal
elsif A_Id not in Boolean_Aspects
- and then A_Id /= Aspect_Alignment
and then Present (Expr)
and then Nkind (Expr) = N_Integer_Literal
then
Delay_Required := False;
+ -- For Alignment and various Size aspects, don't delay for
+ -- an attribute reference whose prefix is Standard, for
+ -- example Standard'Maximum_Alignment or Standard'Word_Size.
+
+ elsif (A_Id = Aspect_Alignment
+ or else A_Id = Aspect_Component_Size
+ or else A_Id = Aspect_Object_Size
+ or else A_Id = Aspect_Size
+ or else A_Id = Aspect_Value_Size)
+ and then Present (Expr)
+ and then Nkind (Expr) = N_Attribute_Reference
+ and then Nkind (Prefix (Expr)) = N_Identifier
+ and then Chars (Prefix (Expr)) = Name_Standard
+ then
+ Delay_Required := False;
+
-- All other cases are delayed
else
-- has aspects that require delayed analysis, the resolution of the
-- aggregate must be deferred to the freeze point of the object. This
-- special processing was created for address clauses, but it must
- -- also apply to Alignment. This must be done before the aspect
+ -- also apply to address aspects. This must be done before the aspect
-- specifications are analyzed because we must handle the aggregate
-- before the analysis of the object declaration is complete.
while Present (A) loop
A_Id := Get_Aspect_Id (Chars (Identifier (A)));
- if A_Id = Aspect_Alignment or else A_Id = Aspect_Address then
+ if A_Id = Aspect_Address then
-- Set flag on object entity, for later processing at
-- the freeze point.