-- the entity is part of a unit compiled with the normal no-argument form
-- of pragma Ada_12 or Ada_2012.
+-- Is_Ada_2022_Only
+-- Defined in all entities, true if a valid pragma Ada_2022 applies to
+-- the entity which specifically names the entity, indicating that the
+-- entity is Ada 2022 only. Note that this flag is not set if the entity
+-- is part of a unit compiled with the normal no-argument form of pragma
+-- Ada_2022.
+
-- Is_Aliased
-- Defined in all entities. Set for objects and types whose declarations
-- carry the keyword aliased, and on record components that have the
-- In_Private_Part
-- Is_Ada_2005_Only
-- Is_Ada_2012_Only
+ -- Is_Ada_2022_Only
-- Is_Bit_Packed_Array (base type only)
-- Is_Aliased
-- Is_Character_Type
Is_Actual_Subtype,
Is_Ada_2005_Only,
Is_Ada_2012_Only,
+ Is_Ada_2022_Only,
Is_Aliased,
Is_Asynchronous,
Is_Atomic,
Sm (In_Use, Flag),
Sm (Is_Ada_2005_Only, Flag),
Sm (Is_Ada_2012_Only, Flag),
+ Sm (Is_Ada_2022_Only, Flag),
Sm (Is_Aliased, Flag),
Sm (Is_Atomic, Flag),
Sm (Is_Bit_Packed_Array, Flag, Impl_Base_Type_Only),
Set_Is_Atomic (I_Typ, Is_Atomic (T));
Set_Is_Ada_2005_Only (I_Typ, Is_Ada_2005_Only (T));
Set_Is_Ada_2012_Only (I_Typ, Is_Ada_2012_Only (T));
+ Set_Is_Ada_2022_Only (I_Typ, Is_Ada_2022_Only (T));
Set_Can_Never_Be_Null (I_Typ);
return I_Typ;
Error_Msg_NE ("& is only defined in Ada 2012?y?", N, E);
end if;
+ -- Warn if reference to Ada 2022 entity not in Ada 2022 mode. We only
+ -- detect real explicit references (modifications and references).
+
+ if Comes_From_Source (N)
+ and then Is_Ada_2022_Only (E)
+ and then not Is_Subprogram (E)
+ and then Ada_Version < Ada_2022
+ and then Warn_On_Ada_2022_Compatibility
+ and then (Typ = 'm' or else Typ = 'r')
+ then
+ Error_Msg_NE ("& is only defined in Ada 2022?y?", N, E);
+
+ -- Error on static and dispatching calls to Ada 2022 subprograms that
+ -- require overriding if we are not in Ada 2022 mode (since overriding
+ -- was skipped); warn if the subprogram does not require overriding.
+
+ elsif Comes_From_Source (N)
+ and then Is_Ada_2022_Only (E)
+ and then Ada_Version < Ada_2022
+ and then Is_Subprogram (E)
+ and then (Typ = 'r' or else Typ = 's' or else Typ = 'R')
+ then
+ if Requires_Overriding (E) then
+ Error_Msg_NE
+ ("& is only defined in Ada 2022 and requires overriding", N, E);
+
+ elsif Warn_On_Ada_2022_Compatibility then
+ Error_Msg_NE ("& is only defined in Ada 2022?y?", N, E);
+ end if;
+ end if;
+
-- Do not generate references if we are within a postcondition sub-
-- program, because the reference does not comes from source, and the
-- preanalysis of the aspect has already created an entry for the ALI
pragma Preelaborable_Initialization (Cursor);
Empty_List : constant List;
+
function Empty return List;
+ pragma Ada_2022 (Empty);
No_Element : constant Cursor;
pragma Preelaborable_Initialization (Cursor);
Empty_List : constant List;
+
function Empty return List;
+ pragma Ada_2022 (Empty);
No_Element : constant Cursor;
Empty_Map : constant Map;
function Empty return Map;
+ pragma Ada_2022 (Empty);
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
Ada.Iterator_Interfaces (Cursor, Has_Element);
function Empty (Capacity : Count_Type := 10) return Vector;
+ pragma Ada_2022 (Empty);
overriding function "=" (Left, Right : Vector) return Boolean;
function New_Vector (First, Last : Index_Type) return Vector
with Pre => First = Index_Type'First;
-- Ada 2022 aggregate operation.
+ pragma Ada_2022 (New_Vector);
function To_Vector (Length : Count_Type) return Vector;
(Container : in out Vector;
Before : Extended_Index;
New_Item : Vector);
+ pragma Ada_2022 (Insert_Vector);
procedure Insert
(Container : in out Vector;
(Container : in out Vector;
Before : Cursor;
New_Item : Vector);
+ pragma Ada_2022 (Insert_Vector);
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor);
+ pragma Ada_2022 (Insert_Vector);
procedure Insert
(Container : in out Vector;
procedure Prepend_Vector
(Container : in out Vector;
New_Item : Vector);
+ pragma Ada_2022 (Prepend_Vector);
procedure Prepend
(Container : in out Vector;
procedure Append_Vector
(Container : in out Vector;
New_Item : Vector);
+ pragma Ada_2022 (Append_Vector);
procedure Append
(Container : in out Vector;
pragma Preelaborable_Initialization (Cursor);
Empty_Map : constant Map;
+
function Empty return Map;
+ pragma Ada_2022 (Empty);
No_Element : constant Cursor;
Set_Is_Ada_2012_Only (Typ);
end if;
+ -- Ada_2022
+
+ if not Has_Rep_Item (Typ, Name_Ada_2022, False)
+ and then Has_Rep_Item (Typ, Name_Ada_2022)
+ and then Is_Pragma_Or_Corr_Pragma_Present_In_Rep_Item
+ (Get_Rep_Item (Typ, Name_Ada_2022))
+ then
+ Set_Is_Ada_2022_Only (Typ);
+ end if;
+
-- Atomic/Shared
if not Has_Rep_Item (Typ, Name_Atomic, Name_Shared, False)
then
null;
+ -- Skip reporting the error on Ada 2022 only subprograms
+ -- that require overriding if we are not in Ada 2022 mode.
+
+ elsif Ada_Version < Ada_2022
+ and then Requires_Overriding (Subp)
+ and then Is_Ada_2022_Only (Ultimate_Alias (Subp))
+ then
+ null;
+
else
Error_Msg_NE
("type must be declared abstract or & overridden",
then
Set_Has_Yield_Aspect (New_Subp, Has_Yield_Aspect (Alias (New_Subp)));
end if;
+
+ Set_Is_Ada_2022_Only (New_Subp, Is_Ada_2022_Only (Parent_Subp));
end Derive_Subprogram;
------------------------
then
Set_Overridden_Operation (Subp, Alias (Overridden_Subp));
Inherit_Subprogram_Contract (Subp, Alias (Overridden_Subp));
+ Set_Is_Ada_2022_Only (Subp,
+ Is_Ada_2022_Only (Alias (Overridden_Subp)));
else
Set_Overridden_Operation (Subp, Overridden_Subp);
Inherit_Subprogram_Contract (Subp, Overridden_Subp);
+ Set_Is_Ada_2022_Only (Subp,
+ Is_Ada_2022_Only (Overridden_Subp));
end if;
end if;
end if;
if Present (Alias (S)) then
Set_Overridden_Operation (E, Alias (S));
Inherit_Subprogram_Contract (E, Alias (S));
+ Set_Is_Ada_2022_Only (E,
+ Is_Ada_2022_Only (Alias (S)));
else
Set_Overridden_Operation (E, S);
Inherit_Subprogram_Contract (E, S);
+ Set_Is_Ada_2022_Only (E, Is_Ada_2022_Only (S));
end if;
-- When a dispatching operation overrides an inherited
then
Set_Overridden_Operation (S, Alias (E));
Inherit_Subprogram_Contract (S, Alias (E));
+ Set_Is_Ada_2022_Only (S,
+ Is_Ada_2022_Only (Alias (E)));
-- Normal case of setting entity as overridden
elsif not Is_Init_Proc (S) then
Set_Overridden_Operation (S, E);
Inherit_Subprogram_Contract (S, E);
+ Set_Is_Ada_2022_Only (S, Is_Ada_2022_Only (E));
end if;
Check_Overriding_Indicator (S, E, Is_Primitive => True);
if Present (Alias (E)) then
Set_Overridden_Operation (S, Alias (E));
Inherit_Subprogram_Contract (S, Alias (E));
+ Set_Is_Ada_2022_Only (S,
+ Is_Ada_2022_Only (Alias (E)));
end if;
end if;
Replace_Elmt (Op_Elmt, New_Op);
Remove_Elmt (Op_List, Op_Elmt_2);
Set_Overridden_Operation (New_Op, Parent_Subp);
+ Set_Is_Ada_2022_Only (New_Op,
+ Is_Ada_2022_Only (Parent_Subp));
-- We don't need to inherit its dispatching slot.
-- Set_All_DT_Position has previously ensured that
Set_Is_Atomic (Priv, Is_Atomic (Full));
Set_Is_Ada_2005_Only (Priv, Is_Ada_2005_Only (Full));
Set_Is_Ada_2012_Only (Priv, Is_Ada_2012_Only (Full));
+ Set_Is_Ada_2022_Only (Priv, Is_Ada_2022_Only (Full));
Set_Has_Pragma_Unmodified (Priv, Has_Pragma_Unmodified (Full));
Set_Has_Pragma_Unreferenced (Priv, Has_Pragma_Unreferenced (Full));
Set_Has_Pragma_Unreferenced_Objects
while Present (Elmt) loop
if Node (Elmt) = Orig_Prim then
Set_Overridden_Operation (S, Prim);
+ Set_Is_Ada_2022_Only (S,
+ Is_Ada_2022_Only (Prim));
Set_Alias (Prim, Orig_Prim);
return Prim;
end if;
Set_Alias (Prev_Op, New_Op);
Set_DTC_Entity (Prev_Op, Empty);
Set_Has_Controlling_Result (New_Op, Has_Controlling_Result (Prev_Op));
+ Set_Is_Ada_2022_Only (New_Op, Is_Ada_2022_Only (Prev_Op));
end if;
end Override_Dispatching_Operation;
--------------
-- pragma Ada_2022;
+ -- pragma Ada_2022 (LOCAL_NAME):
-- Note: this pragma also has some specific processing in Par.Prag
-- because we want to set the Ada 2022 version mode during parsing.
+ -- The one argument form is used for managing the transition from Ada
+ -- 2012 to Ada 2022 in the run-time library. If an entity is marked
+ -- as Ada_2022 only, then referencing the entity in any pre-Ada_2022
+ -- mode will generate a warning;for calls to Ada_2022 only primitives
+ -- that require overriding an error will be reported. In addition, in
+ -- any pre-Ada_2022 mode, a preference rule is established which does
+ -- not choose such an entity unless it is unambiguously specified.
+ -- This avoids extra subprograms marked this way from generating
+ -- ambiguities in otherwise legal pre-Ada 2022 programs. The one
+ -- argument form is intended for exclusive use in the GNAT run-time
+ -- library.
+
when Pragma_Ada_2022 =>
+ declare
+ E_Id : Node_Id;
+
+ begin
GNAT_Pragma;
- Check_Arg_Count (0);
+ if Arg_Count = 1 then
+ Check_Arg_Is_Local_Name (Arg1);
+ E_Id := Get_Pragma_Arg (Arg1);
- Check_Valid_Configuration_Pragma;
+ if Etype (E_Id) = Any_Type then
+ return;
+ end if;
- -- Now set appropriate Ada mode
+ Set_Is_Ada_2022_Only (Entity (E_Id));
+ Record_Rep_Item (Entity (E_Id), N);
+
+ else
+ Check_Arg_Count (0);
+
+ -- For Ada_2022 we unconditionally enforce the documented
+ -- configuration pragma placement, since we do not want to
+ -- tolerate mixed modes in a unit involving Ada 2022. That
+ -- would cause real difficulties for those cases where there
+ -- are incompatibilities between Ada 2012 and Ada 2022. We
+ -- could allow mixing of Ada 2012 and Ada 2022 but it's not
+ -- worth it.
- Ada_Version := Ada_2022;
- Ada_Version_Explicit := Ada_2022;
- Ada_Version_Pragma := N;
+ Check_Valid_Configuration_Pragma;
+
+ -- Now set appropriate Ada mode
+
+ Ada_Version := Ada_2022;
+ Ada_Version_Explicit := Ada_2022;
+ Ada_Version_Pragma := N;
+ end if;
+ end;
-------------------------------------
-- Aggregate_Individually_Assign --
It2 := It;
Nam2 := It.Nam;
- -- Check whether one of the entities is an Ada 2005/2012 and we are
- -- operating in an earlier mode, in which case we discard the Ada
- -- 2005/2012 entity, so that we get proper Ada 95 overload resolution.
+ -- Check whether one of the entities is an Ada 2005/2012/2022 and we
+ -- are operating in an earlier mode, in which case we discard the Ada
+ -- 2005/2012/2022 entity, so that we get proper Ada 95 overload
+ -- resolution.
if Ada_Version < Ada_2005 then
- if Is_Ada_2005_Only (Nam1) or else Is_Ada_2012_Only (Nam1) then
+ if Is_Ada_2005_Only (Nam1)
+ or else Is_Ada_2012_Only (Nam1)
+ or else Is_Ada_2022_Only (Nam1)
+ then
return It2;
- elsif Is_Ada_2005_Only (Nam2) or else Is_Ada_2012_Only (Nam1) then
+
+ elsif Is_Ada_2005_Only (Nam2)
+ or else Is_Ada_2012_Only (Nam2)
+ or else Is_Ada_2022_Only (Nam2)
+ then
+ return It1;
+ end if;
+
+ -- Check whether one of the entities is an Ada 2012/2022 entity and we
+ -- are operating in Ada 2005 mode, in which case we discard the Ada 2012
+ -- Ada 2022 entity, so that we get proper Ada 2005 overload resolution.
+
+ elsif Ada_Version = Ada_2005 then
+ if Is_Ada_2012_Only (Nam1) or else Is_Ada_2022_Only (Nam1) then
+ return It2;
+ elsif Is_Ada_2012_Only (Nam2) or else Is_Ada_2022_Only (Nam2) then
return It1;
end if;
- end if;
- -- Check whether one of the entities is an Ada 2012 entity and we are
- -- operating in Ada 2005 mode, in which case we discard the Ada 2012
- -- entity, so that we get proper Ada 2005 overload resolution.
+ -- Ditto for Ada 2012 vs Ada 2022.
- if Ada_Version = Ada_2005 then
- if Is_Ada_2012_Only (Nam1) then
+ elsif Ada_Version = Ada_2012 then
+ if Is_Ada_2022_Only (Nam1) then
return It2;
- elsif Is_Ada_2012_Only (Nam2) then
+ elsif Is_Ada_2022_Only (Nam2) then
return It1;
end if;
end if;