===================================================================
@@ -8727,6 +8727,10 @@
if the component does not start on a byte boundary, then the scalar storage
order specified for S and for the nested component type shall be identical.
+If @var{S} appears as the type of a record or array component, the enclosing
+record or array shall also have a @code{Scalar_Storage_Order} attribute
+definition clause.
+
No component of a type that has a @code{Scalar_Storage_Order} attribute
definition may be aliased.
===================================================================
@@ -92,11 +92,15 @@
procedure Check_Component_Storage_Order
(Encl_Type : Entity_Id;
- Comp : Entity_Id);
+ Comp : Entity_Id;
+ ADC : Node_Id);
-- For an Encl_Type that has a Scalar_Storage_Order attribute definition
- -- clause, verify that the component type is compatible. For arrays,
- -- Comp is Empty; for records, it is the entity of the component under
- -- consideration.
+ -- clause, verify that the component type has an explicit and compatible
+ -- attribute/aspect. For arrays, Comp is Empty; for records, it is the
+ -- entity of the component under consideration. For an Encl_Type that
+ -- does not have a Scalar_Storage_Order attribute definition clause,
+ -- verify that the component also does not have such a clause.
+ -- ADC is the attribute definition clause if present (or Empty).
procedure Check_Strict_Alignment (E : Entity_Id);
-- E is a base type. If E is tagged or has a component that is aliased
@@ -1068,11 +1072,12 @@
procedure Check_Component_Storage_Order
(Encl_Type : Entity_Id;
- Comp : Entity_Id)
+ Comp : Entity_Id;
+ ADC : Node_Id)
is
Comp_Type : Entity_Id;
+ Comp_ADC : Node_Id;
Err_Node : Node_Id;
- ADC : Node_Id;
Comp_Byte_Aligned : Boolean;
-- Set True for the record case, when Comp starts on a byte boundary
@@ -1113,11 +1118,24 @@
-- the attribute definition clause is attached to the first subtype.
Comp_Type := Base_Type (Comp_Type);
- ADC := Get_Attribute_Definition_Clause
- (First_Subtype (Comp_Type),
- Attribute_Scalar_Storage_Order);
+ Comp_ADC := Get_Attribute_Definition_Clause
+ (First_Subtype (Comp_Type),
+ Attribute_Scalar_Storage_Order);
- if Is_Record_Type (Comp_Type) or else Is_Array_Type (Comp_Type) then
+ -- Case of enclosing type not having explicit SSO: component cannot
+ -- have it either.
+
+ if No (ADC) then
+ if Present (Comp_ADC) then
+ Error_Msg_N
+ ("composite type must have explicit scalar storage order",
+ Err_Node);
+ end if;
+
+ -- Case of enclosing type having explicit SSO: check compatible
+ -- attribute on Comp_Type if composite.
+
+ elsif Is_Record_Type (Comp_Type) or else Is_Array_Type (Comp_Type) then
if Present (Comp) and then Chars (Comp) = Name_uParent then
if Reverse_Storage_Order (Encl_Type)
/=
@@ -1142,6 +1160,9 @@
& "storage order as enclosing composite", Err_Node);
end if;
+ -- Enclosing type has explicit SSO, non-composite component must not
+ -- be aliased.
+
elsif Component_Aliased then
Error_Msg_N
("aliased component not permitted for type with "
@@ -2312,11 +2333,12 @@
-- Check for scalar storage order
- if Present (Get_Attribute_Definition_Clause
- (Arr, Attribute_Scalar_Storage_Order))
- then
- Check_Component_Storage_Order (Arr, Empty);
- end if;
+ Check_Component_Storage_Order
+ (Encl_Type => Arr,
+ Comp => Empty,
+ ADC => Get_Attribute_Definition_Clause
+ (First_Subtype (Arr),
+ Attribute_Scalar_Storage_Order));
-- Processing that is done only for subtypes
@@ -2999,15 +3021,16 @@
("??scalar storage order specified but no component clause",
ADC);
end if;
+ end if;
- -- Check attribute on component types
+ -- Check consistent attribute setting on component types
- Comp := First_Component (Rec);
- while Present (Comp) loop
- Check_Component_Storage_Order (Rec, Comp);
- Next_Component (Comp);
- end loop;
- end if;
+ Comp := First_Component (Rec);
+ while Present (Comp) loop
+ Check_Component_Storage_Order
+ (Encl_Type => Rec, Comp => Comp, ADC => ADC);
+ Next_Component (Comp);
+ end loop;
-- Deal with Bit_Order aspect specifying a non-default bit order