Set_Raises_Constraint_Error (N);
end if;
+ -- RM 13.14(8/4): a nonstatic expression in a spec expression does
+ -- not cause freezing, so the representation attributes cannot be
+ -- evaluated at this point if the type is not already frozen.
+
+ if not Static
+ and then In_Spec_Expression
+ and then Id in Attribute_Alignment
+ | Attribute_Component_Size
+ | Attribute_Max_Alignment_For_Allocation
+ | Attribute_Max_Size_In_Storage_Elements
+ | Attribute_Object_Size
+ | Attribute_Size
+ | Attribute_Small
+ | Attribute_VADS_Size
+ | Attribute_Value_Size
+ and then not Is_Frozen (P_Type)
+ then
+ return;
+ end if;
+
-- Array case. We enforce the constrained requirement of (RM 4.9(7-8))
-- since we can't do anything with unconstrained arrays. In addition,
-- only the First, Last and Length attributes are possibly static.
-- If not a deferred constant, then the object declaration freezes
-- its type, unless the object is of an anonymous type and has delayed
- -- aspects. In that case the type is frozen when the object itself is.
+ -- aspects (in that case the type is frozen when the object itself is)
+ -- or the context is a spec expression.
else
Check_Fully_Declared (T, N);
and then Is_Itype (T)
then
Set_Has_Delayed_Freeze (T);
- else
+ elsif not In_Spec_Expression then
Freeze_Before (N, T);
end if;
end if;