diff mbox series

[Ada] New pragma Ada_2020

Message ID 20170908133600.GA100516@adacore.com
State New
Headers show
Series [Ada] New pragma Ada_2020 | expand

Commit Message

Arnaud Charlet Sept. 8, 2017, 1:36 p.m. UTC
This patch allows pragma Ada_2020 to be used to enable Ada 2020 features
that have been implemented in GNAT. Ada_2020 is a configuration
pragma. This is in addition to the -gnat2020 command-line switch.

Note: There is no synonym pragma Ada_20. We have Ada_05 and Ada_12, but
we decided long ago that for years after 2000, four-digit numbers look
better.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-08  Bob Duff  <duff@adacore.com>

	* par-prag.adb, sem_prag.adb, snames.ads-tmpl: Implement pragma
	Ada_2020, along the same lines as the other Ada version pragmas.
diff mbox series

Patch

Index: par-prag.adb
===================================================================
--- par-prag.adb	(revision 251892)
+++ par-prag.adb	(working copy)
@@ -326,14 +326,16 @@ 
 
    case Prag_Id is
 
+      --  Ada version pragmas must be processed at parse time, because we want
+      --  to set the Ada version properly at parse time to recognize the
+      --  appropriate Ada version syntax. However, pragma Ada_2005 and higher
+      --  have an optional argument; it is only the zero argument form that
+      --  must be processed at parse time.
+
       ------------
       -- Ada_83 --
       ------------
 
-      --  This pragma must be processed at parse time, since we want to set
-      --  the Ada version properly at parse time to recognize the appropriate
-      --  Ada version syntax.
-
       when Pragma_Ada_83 =>
          if not Latest_Ada_Only then
             Ada_Version := Ada_83;
@@ -345,10 +347,6 @@ 
       -- Ada_95 --
       ------------
 
-      --  This pragma must be processed at parse time, since we want to set
-      --  the Ada version properly at parse time to recognize the appropriate
-      --  Ada version syntax.
-
       when Pragma_Ada_95 =>
          if not Latest_Ada_Only then
             Ada_Version := Ada_95;
@@ -360,11 +358,6 @@ 
       -- Ada_05/Ada_2005 --
       ---------------------
 
-      --  These pragmas must be processed at parse time, since we want to set
-      --  the Ada version properly at parse time to recognize the appropriate
-      --  Ada version syntax. However, it is only the zero argument form that
-      --  must be processed at parse time.
-
       when Pragma_Ada_05
          | Pragma_Ada_2005
       =>
@@ -378,11 +371,6 @@ 
       -- Ada_12/Ada_2012 --
       ---------------------
 
-      --  These pragmas must be processed at parse time, since we want to set
-      --  the Ada version properly at parse time to recognize the appropriate
-      --  Ada version syntax. However, it is only the zero argument form that
-      --  must be processed at parse time.
-
       when Pragma_Ada_12
          | Pragma_Ada_2012
       =>
@@ -392,6 +380,17 @@ 
             Ada_Version_Pragma := Pragma_Node;
          end if;
 
+      --------------
+      -- Ada_2020 --
+      --------------
+
+      when Pragma_Ada_2020 =>
+         if Arg_Count = 0 then
+            Ada_Version := Ada_2020;
+            Ada_Version_Explicit := Ada_2020;
+            Ada_Version_Pragma := Pragma_Node;
+         end if;
+
       ---------------------------
       -- Compiler_Unit_Warning --
       ---------------------------
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 251893)
+++ sem_prag.adb	(working copy)
@@ -11835,7 +11835,7 @@ 
 
          --  The one argument form is used for managing the transition from Ada
          --  2005 to Ada 2012 in the run-time library. If an entity is marked
-         --  as Ada_201 only, then referencing the entity in any pre-Ada_2012
+         --  as Ada_2012 only, then referencing the entity in any pre-Ada_2012
          --  mode will generate a warning. In addition, in any pre-Ada_2012
          --  mode, a preference rule is established which does not choose
          --  such an entity unless it is unambiguously specified. This avoids
@@ -11883,6 +11883,28 @@ 
             end if;
          end;
 
+         --------------
+         -- Ada_2020 --
+         --------------
+
+         --  pragma Ada_2020;
+
+         --  Note: this pragma also has some specific processing in Par.Prag
+         --  because we want to set the Ada 2020 version mode during parsing.
+
+         when Pragma_Ada_2020 =>
+            GNAT_Pragma;
+
+            Check_Arg_Count (0);
+
+            Check_Valid_Configuration_Pragma;
+
+            --  Now set appropriate Ada mode
+
+            Ada_Version          := Ada_2020;
+            Ada_Version_Explicit := Ada_2020;
+            Ada_Version_Pragma   := N;
+
          ----------------------
          -- All_Calls_Remote --
          ----------------------
@@ -29419,6 +29441,7 @@ 
       Pragma_Ada_2005                       => -1,
       Pragma_Ada_12                         => -1,
       Pragma_Ada_2012                       => -1,
+      Pragma_Ada_2020                       => -1,
       Pragma_All_Calls_Remote               => -1,
       Pragma_Allow_Integer_Address          => -1,
       Pragma_Annotate                       => 93,
Index: snames.ads-tmpl
===================================================================
--- snames.ads-tmpl	(revision 251892)
+++ snames.ads-tmpl	(working copy)
@@ -388,6 +388,7 @@ 
    Name_Ada_2005                       : constant Name_Id := N + $; -- GNAT
    Name_Ada_12                         : constant Name_Id := N + $; -- GNAT
    Name_Ada_2012                       : constant Name_Id := N + $; -- GNAT
+   Name_Ada_2020                       : constant Name_Id := N + $; -- GNAT
    Name_Allow_Integer_Address          : constant Name_Id := N + $; -- GNAT
    Name_Annotate                       : constant Name_Id := N + $; -- GNAT
    Name_Assertion_Policy               : constant Name_Id := N + $; -- Ada 05
@@ -1779,6 +1780,9 @@ 
       Pragma_Ada_2005,
       Pragma_Ada_12,
       Pragma_Ada_2012,
+      Pragma_Ada_2020,
+      --  Note that there is no Pragma_Ada_20. Pragma_Ada_05/12 are for
+      --  compatibility reasons only; the full year names are preferred.
       Pragma_Allow_Integer_Address,
       Pragma_Annotate,
       Pragma_Assertion_Policy,