public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1610] [Ada] Ada2020: Special handling of types derived from runtime
@ 2021-06-18  8:37 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-18  8:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:07537fe632cd6e2fcf83954fb85455d118d80c06

commit r12-1610-g07537fe632cd6e2fcf83954fb85455d118d80c06
Author: Javier Miranda <miranda@adacore.com>
Date:   Sat Mar 13 14:47:59 2021 -0500

    [Ada] Ada2020: Special handling of types derived from runtime
    
    gcc/ada/
    
            * einfo.ads (Is_Ada_2022_Only): Adding documentation.
            * gen_il-fields.ads (Is_Ada_2022_Only): New flag.
            * gen_il-gen-gen_entities.adb (Is_Ada_2022_Only): New flag.
            * itypes.adb (Create_Null_Excluding_Itype): Inherit
            Is_Ada_2022_Only.
            * sem_ch3.adb (Check_Abstract_Overriding): Skip reporting error
            on Ada 2022 only subprograms that require overriding if we are
            not in Ada 2022 mode.
            (Derive_Subprogram): Inherit Is_Ada_2022_Only.
            * sem_ch6.adb (Check_Overriding_Indicator): Inherit
            Is_Ada_2022_Only.
            (New_Overloaded_Entity): Inherit Is_Ada_2022_Only.
            * sem_ch7.adb (Declare_Inherited_Private_Subprograms): Inherit
            Is_Ada_2022_Only.
            (Preserve_Full_Attributes): Inherit Is_Ada_2022_Only.
            * sem_disp.adb (Find_Hidden_Overridden_Primitive): Inherit
            Is_Ada_2022_Only.
            (Override_Dispatching_Operation): Inherit Is_Ada_2022_Only.
            * sem_prag.adb (Analyze_Pragma): Allow form with argument for
            Ada 2022.
            * sem_type.adb: (Disambiguate): Deal with Is_Ada_2022_Only
            * lib-xref.adb (Generate_Reference): Error on static and
            dispatching calls to Ada 2022 subprograms that require
            overriding if we are not in Ada 2022 mode; warn on other
            references to Ada 2022 entities when not in Ada 2022 mode.
            * sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Inherit
            Ada_2020_Only.
            * libgnat/a-cdlili.ads (Empty): Adding pragma Ada_2022.
            * libgnat/a-cidlli.ads (Empty): Adding pragma Ada_2022.
            * libgnat/a-ciorma.ads (Empty): Adding pragma Ada_2022.
            * libgnat/a-cobove.ads (Empty): Adding pragma Ada_2022.
            * libgnat/a-coorma.ads (Empty): Adding pragma Ada_2022.
            (New_Vector): Adding pragma Ada_2022.
            (Insert_Vector): Adding pragma Ada_2022.
            (Prepend_Vector): Adding pragma Ada_2022.
            (Append_Vector): Adding pragma Ada_2022.

Diff:
---
 gcc/ada/einfo.ads                   |  8 ++++++
 gcc/ada/gen_il-fields.ads           |  1 +
 gcc/ada/gen_il-gen-gen_entities.adb |  1 +
 gcc/ada/itypes.adb                  |  1 +
 gcc/ada/lib-xref.adb                | 31 ++++++++++++++++++++++
 gcc/ada/libgnat/a-cdlili.ads        |  2 ++
 gcc/ada/libgnat/a-cidlli.ads        |  2 ++
 gcc/ada/libgnat/a-ciorma.ads        |  1 +
 gcc/ada/libgnat/a-cobove.ads        |  7 +++++
 gcc/ada/libgnat/a-coorma.ads        |  2 ++
 gcc/ada/sem_ch13.adb                | 10 ++++++++
 gcc/ada/sem_ch3.adb                 | 11 ++++++++
 gcc/ada/sem_ch6.adb                 | 12 +++++++++
 gcc/ada/sem_ch7.adb                 |  3 +++
 gcc/ada/sem_disp.adb                |  3 +++
 gcc/ada/sem_prag.adb                | 51 ++++++++++++++++++++++++++++++++-----
 gcc/ada/sem_type.adb                | 40 ++++++++++++++++++++---------
 17 files changed, 168 insertions(+), 18 deletions(-)

diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 55cf83d847e..471056c5441 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -2317,6 +2317,13 @@ package Einfo is
 --       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
@@ -4871,6 +4878,7 @@ package Einfo is
    --    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
diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads
index 4aac802819a..2f0df43c606 100644
--- a/gcc/ada/gen_il-fields.ads
+++ b/gcc/ada/gen_il-fields.ads
@@ -669,6 +669,7 @@ package Gen_IL.Fields is
       Is_Actual_Subtype,
       Is_Ada_2005_Only,
       Is_Ada_2012_Only,
+      Is_Ada_2022_Only,
       Is_Aliased,
       Is_Asynchronous,
       Is_Atomic,
diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb
index afd3ec47696..2e745c2f939 100644
--- a/gcc/ada/gen_il-gen-gen_entities.adb
+++ b/gcc/ada/gen_il-gen-gen_entities.adb
@@ -119,6 +119,7 @@ begin -- Gen_IL.Gen.Gen_Entities
         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),
diff --git a/gcc/ada/itypes.adb b/gcc/ada/itypes.adb
index 3282d11375e..f51b44a4412 100644
--- a/gcc/ada/itypes.adb
+++ b/gcc/ada/itypes.adb
@@ -111,6 +111,7 @@ package body Itypes is
       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;
diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
index a426745a0cd..17de8864bef 100644
--- a/gcc/ada/lib-xref.adb
+++ b/gcc/ada/lib-xref.adb
@@ -703,6 +703,37 @@ package body Lib.Xref is
          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
diff --git a/gcc/ada/libgnat/a-cdlili.ads b/gcc/ada/libgnat/a-cdlili.ads
index aed02bc0e06..8d2d345b066 100644
--- a/gcc/ada/libgnat/a-cdlili.ads
+++ b/gcc/ada/libgnat/a-cdlili.ads
@@ -66,7 +66,9 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_List : constant List;
+
    function Empty return List;
+   pragma Ada_2022 (Empty);
 
    No_Element : constant Cursor;
 
diff --git a/gcc/ada/libgnat/a-cidlli.ads b/gcc/ada/libgnat/a-cidlli.ads
index ee92e712391..d5c4e45e32b 100644
--- a/gcc/ada/libgnat/a-cidlli.ads
+++ b/gcc/ada/libgnat/a-cidlli.ads
@@ -65,7 +65,9 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_List : constant List;
+
    function Empty return List;
+   pragma Ada_2022 (Empty);
 
    No_Element : constant Cursor;
 
diff --git a/gcc/ada/libgnat/a-ciorma.ads b/gcc/ada/libgnat/a-ciorma.ads
index 734fdb21bfa..68e9b93c035 100644
--- a/gcc/ada/libgnat/a-ciorma.ads
+++ b/gcc/ada/libgnat/a-ciorma.ads
@@ -70,6 +70,7 @@ is
    Empty_Map : constant Map;
 
    function Empty return Map;
+   pragma Ada_2022 (Empty);
 
    No_Element : constant Cursor;
    function Has_Element (Position : Cursor) return Boolean;
diff --git a/gcc/ada/libgnat/a-cobove.ads b/gcc/ada/libgnat/a-cobove.ads
index e808d85cd0f..eb8072d4018 100644
--- a/gcc/ada/libgnat/a-cobove.ads
+++ b/gcc/ada/libgnat/a-cobove.ads
@@ -80,12 +80,14 @@ package Ada.Containers.Bounded_Vectors is
       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;
 
@@ -194,6 +196,7 @@ package Ada.Containers.Bounded_Vectors is
      (Container : in out Vector;
       Before    : Extended_Index;
       New_Item  : Vector);
+   pragma Ada_2022 (Insert_Vector);
 
    procedure Insert
      (Container : in out Vector;
@@ -205,6 +208,7 @@ package Ada.Containers.Bounded_Vectors is
      (Container : in out Vector;
       Before    : Cursor;
       New_Item  : Vector);
+   pragma Ada_2022 (Insert_Vector);
 
    procedure Insert
      (Container : in out Vector;
@@ -217,6 +221,7 @@ package Ada.Containers.Bounded_Vectors is
       Before    : Cursor;
       New_Item  : Vector;
       Position  : out Cursor);
+   pragma Ada_2022 (Insert_Vector);
 
    procedure Insert
      (Container : in out Vector;
@@ -258,6 +263,7 @@ package Ada.Containers.Bounded_Vectors is
    procedure Prepend_Vector
      (Container : in out Vector;
       New_Item  : Vector);
+   pragma Ada_2022 (Prepend_Vector);
 
    procedure Prepend
      (Container : in out Vector;
@@ -272,6 +278,7 @@ package Ada.Containers.Bounded_Vectors is
    procedure Append_Vector
      (Container : in out Vector;
       New_Item  : Vector);
+   pragma Ada_2022 (Append_Vector);
 
    procedure Append
      (Container : in out Vector;
diff --git a/gcc/ada/libgnat/a-coorma.ads b/gcc/ada/libgnat/a-coorma.ads
index 735b0b18bc9..5740621c921 100644
--- a/gcc/ada/libgnat/a-coorma.ads
+++ b/gcc/ada/libgnat/a-coorma.ads
@@ -67,7 +67,9 @@ is
    pragma Preelaborable_Initialization (Cursor);
 
    Empty_Map : constant Map;
+
    function Empty return Map;
+   pragma Ada_2022 (Empty);
 
    No_Element : constant Cursor;
 
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 3c3e35150e9..35e0b9236ab 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -13399,6 +13399,16 @@ package body Sem_Ch13 is
          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)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index d807b10c2f0..a762a6199f0 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -10967,6 +10967,15 @@ package body Sem_Ch3 is
                   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",
@@ -16061,6 +16070,8 @@ package body Sem_Ch3 is
       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;
 
    ------------------------
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 68e10afc7cc..7bca9df7225 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -7271,10 +7271,14 @@ package body Sem_Ch6 is
                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;
@@ -11888,10 +11892,13 @@ package body Sem_Ch6 is
                   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
@@ -12058,6 +12065,8 @@ package body Sem_Ch6 is
                   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
 
@@ -12071,6 +12080,7 @@ package body Sem_Ch6 is
                   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);
@@ -12099,6 +12109,8 @@ package body Sem_Ch6 is
                      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;
 
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 27927ebf840..69ad184948a 100644
--- a/gcc/ada/sem_ch7.adb
+++ b/gcc/ada/sem_ch7.adb
@@ -2061,6 +2061,8 @@ package body Sem_Ch7 is
                            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
@@ -2725,6 +2727,7 @@ package body Sem_Ch7 is
          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
diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb
index 20e3e93911a..903182664bf 100644
--- a/gcc/ada/sem_disp.adb
+++ b/gcc/ada/sem_disp.adb
@@ -2199,6 +2199,8 @@ package body Sem_Disp is
                      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;
@@ -2761,6 +2763,7 @@ package body Sem_Disp is
          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;
 
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 1a1fc74c572..a65864dfa83 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -12542,22 +12542,61 @@ package body Sem_Prag is
          --------------
 
          --  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 --
diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb
index 2998d2f8eb1..396f616cbf1 100644
--- a/gcc/ada/sem_type.adb
+++ b/gcc/ada/sem_type.adb
@@ -1810,26 +1810,42 @@ package body Sem_Type is
       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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-18  8:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  8:37 [gcc r12-1610] [Ada] Ada2020: Special handling of types derived from runtime Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).