------------------------------------------------------------------------------
with Atree; use Atree;
+with Debug; use Debug;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
begin
-- Aspect Unsigned_Base_Range temporarily disabled
- if Name = Name_Unsigned_Base_Range then
+ if Name = Name_Unsigned_Base_Range
+ and then not Debug_Flag_Dot_U
+ then
return No_Aspect;
end if;
-- d.r Disable reordering of components in record types
-- d.s Strict secondary stack management
-- d.t Disable static allocation of library level dispatch tables
- -- d.u
+ -- d.u Enable Unsigned_Base_Range aspect language extension
-- d.v Enforce SPARK elaboration rules in SPARK code
-- d.w Do not check for infinite loops
-- d.x No exception handlers
-- previous dynamic construction of tables. It is there as a possible
-- work around if we run into trouble with the new implementation.
- -- d.u
+ -- d.u Enable the support for Unsigned_Base_Range aspect, attribute, and
+ -- pragma.
-- d.v This flag enforces the elaboration rules defined in the SPARK
-- Reference Manual, chapter 7.7, to all SPARK code within a unit. As
function Is_Modular_Integer_Type (Id : E) return B is
begin
- return Ekind (Id) in Modular_Integer_Kind;
+ return Ekind (Id) in Modular_Integer_Kind
+ and then not Has_Unsigned_Base_Range_Aspect (Base_Type (Id));
end Is_Modular_Integer_Type;
function Is_Named_Access_Type (Id : E) return B is
function Is_Signed_Integer_Type (Id : E) return B is
begin
- return Ekind (Id) in Signed_Integer_Kind;
+ return Ekind (Id) in Signed_Integer_Kind
+ or else
+ (Ekind (Id) in Modular_Integer_Kind
+ and then Has_Unsigned_Base_Range_Aspect (Base_Type (Id)));
end Is_Signed_Integer_Type;
function Is_Subprogram (Id : E) return B is
-- Non_Binary_Modulus (base type only)
-- Has_Biased_Representation
-- Has_Shift_Operator (base type only)
+ -- Has_Unsigned_Base_Range_Aspect (base type only)
-- No_Predicate_On_Actual
-- No_Dynamic_Predicate_On_Actual
-- Type_Low_Bound (synth)
-- Attribute Unsigned_Base_Range temporarily disabled
if not Is_Attribute_Name (Attr_Name)
- or else Attr_Name = Name_Unsigned_Base_Range
+ or else (Attr_Name = Name_Unsigned_Base_Range
+ and then not Debug_Flag_Dot_U)
then
if Apostrophe_Should_Be_Semicolon then
Expr_Form := EF_Name;
| Aspect_Effective_Reads
| Aspect_Effective_Writes
| Aspect_Preelaborable_Initialization
+ | Aspect_Unsigned_Base_Range
then
Error_Msg_Name_1 := Nam;
then
Delay_Required := False;
+ -- For Unsigned_Base_Range aspect, do not delay becase we
+ -- need to process it before any type or subtype derivation
+ -- is analyzed.
+
+ elsif A_Id in Aspect_Unsigned_Base_Range then
+ Delay_Required := False;
+
-- All other cases are delayed
else
-- not. It is OK for the new bound we are creating, but not for
-- the old one??? Still if it never happens, no problem.
- Analyze_And_Resolve (Bound, Base_Type (Par_T));
+ -- This must be disabled on unsigned base range types because their
+ -- base type is a modular type, and their type is a signed integer
+ -- type.
+
+ if not Has_Unsigned_Base_Range_Aspect (Base_Type (Par_T)) then
+ Analyze_And_Resolve (Bound, Base_Type (Par_T));
+ end if;
if Nkind (Bound) in N_Integer_Literal | N_Real_Literal then
New_Bound := New_Copy (Bound);
-- Pragma Unsigned_Base_Range temporarily disabled
if not Is_Pragma_Name (Pname)
- or else Pname = Name_Unsigned_Base_Range
+ or else (Pname = Name_Unsigned_Base_Range
+ and then not Debug_Flag_Dot_U)
then
declare
Msg_Issued : Boolean := False;
then
Error_Pragma_Arg
("cannot apply pragma %",
- "\& is not a signed integer type",
- Arg1);
+ "\& is not a signed integer type", Arg1);
elsif Is_Derived_Type (E) then
Error_Pragma_Arg
("pragma % cannot apply to derived type", Arg1);
+
+ elsif Is_Generic_Type (E) then
+ Error_Pragma_Arg
+ ("pragma % cannot apply to formal type", Arg1);
+
+ elsif Present (Expr)
+ and then Is_False (Expr_Value (Expr))
+ and then Ekind (Base_Type (E)) = E_Modular_Integer_Type
+ and then Has_Unsigned_Base_Range_Aspect (Base_Type (E))
+ then
+ Error_Pragma_Arg
+ ("pragma % can only confirm previous True value", Arg1);
end if;
Check_First_Subtype (Arg1);
-- Create the new unsigned integer base type entity, and apply
-- the constraint to create the first subtype of E.
- Unsigned_Base_Range_Type_Declaration (E,
- Def => Type_Definition (Parent (E)));
+ if No (Expr) or else Is_True (Expr_Value (Expr)) then
+ Unsigned_Base_Range_Type_Declaration (E,
+ Def => Type_Definition (Parent (E)));
- Set_Direct_Primitive_Operations (Base_Type (E), New_Elmt_List);
- Set_Direct_Primitive_Operations (E,
- Direct_Primitive_Operations (Base_Type (E)));
- Ensure_Freeze_Node (Base_Type (E));
- Set_First_Subtype_Link (Freeze_Node (Base_Type (E)), E);
- Set_Has_Delayed_Freeze (E);
+ Set_Direct_Primitive_Operations (Base_Type (E), New_Elmt_List);
+ Set_Direct_Primitive_Operations (E,
+ Direct_Primitive_Operations (Base_Type (E)));
+ Ensure_Freeze_Node (Base_Type (E));
+ Set_First_Subtype_Link (Freeze_Node (Base_Type (E)), E);
+ Set_Has_Delayed_Freeze (E);
- Set_Has_Unsigned_Base_Range_Aspect (Base_Type (E));
+ Set_Has_Unsigned_Base_Range_Aspect (Base_Type (E));
+ end if;
end Unsigned_Base_Range;
----------------