]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Turn GNAT_Annotate into its own pragma
authorGhjuvan Lacambre <lacambre@adacore.com>
Wed, 17 Mar 2021 17:33:34 +0000 (18:33 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 5 Jul 2021 13:09:11 +0000 (13:09 +0000)
gcc/ada/

* aspects.ads: Add GNAT_Annotate aspect.
* gnat1drv.adb (Adjust_Global_Switches): Stop defining
Name_Gnat_Annotate as an alias of Name_Annotate.
* snames.ads-tmpl: Define Gnat_Annotate.
* par-prag.adb, sem_prag.ads: Add Pragma_Gnat_Annotate to list
of pragmas.
* lib-writ.adb, sem_ch13.adb, sem_prag.adb: Handle Gnat_Annotate
like Aspect_Annotate.

gcc/ada/aspects.ads
gcc/ada/gnat1drv.adb
gcc/ada/lib-writ.adb
gcc/ada/par-prag.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_prag.ads
gcc/ada/snames.ads-tmpl

index 2cbb2da353e50d1e703da189aa46c6163414e04e..0f9ed232c8029c8770dffce8215f273c01f41570 100644 (file)
@@ -100,6 +100,7 @@ package Aspects is
       Aspect_External_Tag,
       Aspect_Ghost,                         -- GNAT
       Aspect_Global,                        -- GNAT
+      Aspect_GNAT_Annotate,                 -- GNAT
       Aspect_Implicit_Dereference,
       Aspect_Initial_Condition,             -- GNAT
       Aspect_Initializes,                   -- GNAT
@@ -269,6 +270,7 @@ package Aspects is
       Aspect_Favor_Top_Level            => True,
       Aspect_Ghost                      => True,
       Aspect_Global                     => True,
+      Aspect_GNAT_Annotate              => True,
       Aspect_Inline_Always              => True,
       Aspect_Invariant                  => True,
       Aspect_Lock_Free                  => True,
@@ -318,9 +320,10 @@ package Aspects is
    --  the same aspect attached to the same declaration are allowed.
 
    No_Duplicates_Allowed : constant array (Aspect_Id) of Boolean :=
-     (Aspect_Annotate  => False,
-      Aspect_Test_Case => False,
-      others           => True);
+     (Aspect_Annotate      => False,
+      Aspect_GNAT_Annotate => False,
+      Aspect_Test_Case     => False,
+      others               => True);
 
    --  The following subtype defines aspects corresponding to library unit
    --  pragmas, these can only validly appear as aspects for library units,
@@ -387,6 +390,7 @@ package Aspects is
       Aspect_External_Tag               => Expression,
       Aspect_Ghost                      => Optional_Expression,
       Aspect_Global                     => Expression,
+      Aspect_GNAT_Annotate              => Expression,
       Aspect_Implicit_Dereference       => Name,
       Aspect_Initial_Condition          => Expression,
       Aspect_Initializes                => Expression,
@@ -491,6 +495,7 @@ package Aspects is
       Aspect_External_Tag                 => False,
       Aspect_Ghost                        => False,
       Aspect_Global                       => False,
+      Aspect_GNAT_Annotate               => False,
       Aspect_Implicit_Dereference         => False,
       Aspect_Initial_Condition            => False,
       Aspect_Initializes                  => False,
@@ -647,6 +652,7 @@ package Aspects is
       Aspect_Full_Access_Only             => Name_Full_Access_Only,
       Aspect_Ghost                        => Name_Ghost,
       Aspect_Global                       => Name_Global,
+      Aspect_GNAT_Annotate                => Name_GNAT_Annotate,
       Aspect_Implicit_Dereference         => Name_Implicit_Dereference,
       Aspect_Import                       => Name_Import,
       Aspect_Independent                  => Name_Independent,
@@ -957,6 +963,7 @@ package Aspects is
       Aspect_Extensions_Visible           => Never_Delay,
       Aspect_Ghost                        => Never_Delay,
       Aspect_Global                       => Never_Delay,
+      Aspect_GNAT_Annotate                => Never_Delay,
       Aspect_Import                       => Never_Delay,
       Aspect_Initial_Condition            => Never_Delay,
       Aspect_Initializes                  => Never_Delay,
index 59b9595cf2fedafe25bc288e1c71e58b99dfbc31..22c93113709c071125280ab16745d0b047b0cab2 100644 (file)
@@ -67,7 +67,6 @@ with Sem_Type;
 with Set_Targ;
 with Sinfo;          use Sinfo;
 with Sinfo.Nodes;    use Sinfo.Nodes;
-with Sinfo.Utils;    use Sinfo.Utils;
 with Sinput;         use Sinput;
 with Sinput.L;       use Sinput.L;
 with Snames;         use Snames;
@@ -146,12 +145,6 @@ procedure Gnat1drv is
    --  Start of processing for Adjust_Global_Switches
 
    begin
-      --  Define pragma GNAT_Annotate as an alias of pragma Annotate, to be
-      --  able to work around bootstrap limitations with the old syntax of
-      --  pragma Annotate, and use pragma GNAT_Annotate in compiler sources
-      --  when needed.
-
-      Map_Pragma_Name (From => Name_Gnat_Annotate, To => Name_Annotate);
 
       --  -gnatd_U disables prepending error messages with "error:"
 
index 4dfb68e03a0f4047aa71e92194877424dafc1aee..16993dd8f43182d2aef80c945f7f34e74cccbc34 100644 (file)
@@ -709,7 +709,7 @@ package body Lib.Writ is
                   Write_Info_Char (' ');
 
                   case Pragma_Name (N) is
-                     when Name_Annotate =>
+                     when Name_Annotate | Name_GNAT_Annotate =>
                         C := 'A';
                      when Name_Comment =>
                         C := 'C';
index d701c2ccd155c14ac9fb9df7fbc51570ed5f5869..06c7d877fe226eeabc82d98aba1d763a1fc1ac1a 100644 (file)
@@ -1389,6 +1389,7 @@ begin
          | Pragma_Finalize_Storage_Only
          | Pragma_Ghost
          | Pragma_Global
+         | Pragma_GNAT_Annotate
          | Pragma_Ident
          | Pragma_Implementation_Defined
          | Pragma_Implemented
index 83d7d3c92bcd78f9f081866d5b8df42a92c49f4b..cdc00832e931ea5592e5cd422e71657529689b26 100644 (file)
@@ -4199,7 +4199,7 @@ package body Sem_Ch13 is
 
                --  Case 2e: Annotate aspect
 
-               when Aspect_Annotate =>
+               when Aspect_Annotate | Aspect_GNAT_Annotate =>
                   declare
                      Args  : List_Id;
                      Pargs : List_Id;
@@ -11117,6 +11117,7 @@ package body Sem_Ch13 is
             | Aspect_Extensions_Visible
             | Aspect_Ghost
             | Aspect_Global
+            | Aspect_GNAT_Annotate
             | Aspect_Implicit_Dereference
             | Aspect_Initial_Condition
             | Aspect_Initializes
index 14351b3f3be3e9ff8254ea9a7c505405d2f149ab..36b305eec31ffc5168e842a7a6f94fb5c24e97ce 100644 (file)
@@ -12688,7 +12688,7 @@ package body Sem_Prag is
          --  external tool and a tool-specific function. These arguments are
          --  not analyzed.
 
-         when Pragma_Annotate => Annotate : declare
+         when Pragma_Annotate | Pragma_GNAT_Annotate => Annotate : declare
             Arg     : Node_Id;
             Expr    : Node_Id;
             Nam_Arg : Node_Id;
@@ -31246,6 +31246,7 @@ package body Sem_Prag is
       Pragma_Finalize_Storage_Only          =>  0,
       Pragma_Ghost                          =>  0,
       Pragma_Global                         => -1,
+      Pragma_GNAT_Annotate                  => 93,
       Pragma_Ident                          => -1,
       Pragma_Ignore_Pragma                  =>  0,
       Pragma_Implementation_Defined         => -1,
index c620bebc3f5396f9e05140af9dc2e7adf9da5060..e1664811f5066d11e347734e0a5746a11ca25e26 100644 (file)
@@ -63,6 +63,7 @@ package Sem_Prag is
       Pragma_Favor_Top_Level              => True,
       Pragma_Ghost                        => True,
       Pragma_Global                       => True,
+      Pragma_GNAT_Annotate                => True,
       Pragma_Import                       => True,
       Pragma_Independent                  => True,
       Pragma_Independent_Components       => True,
index b9ca6071d28061c8be257766c92eaf338b653be7..837a878cfdad8bb956db70b61ea5b45b08e2f2a8 100644 (file)
@@ -439,6 +439,7 @@ package Snames is
    --  correctly recognize and process Fast_Math.
 
    Name_Favor_Top_Level                : constant Name_Id := N + $; -- GNAT
+   Name_GNAT_Annotate                  : constant Name_Id := N + $; -- GNAT
    Name_Ignore_Pragma                  : constant Name_Id := N + $; -- GNAT
    Name_Implicit_Packing               : constant Name_Id := N + $; -- GNAT
    Name_Initialize_Scalars             : constant Name_Id := N + $; -- GNAT
@@ -796,7 +797,6 @@ package Snames is
    Name_Gcc                            : constant Name_Id := N + $;
    Name_General                        : constant Name_Id := N + $;
    Name_Gnat                           : constant Name_Id := N + $;
-   Name_Gnat_Annotate                  : constant Name_Id := N + $;
    Name_Gnat_Extended_Ravenscar        : constant Name_Id := N + $;
    Name_Gnat_Ravenscar_EDF             : constant Name_Id := N + $;
    Name_Gnatprove                      : constant Name_Id := N + $;
@@ -1767,6 +1767,7 @@ package Snames is
       Pragma_Extensions_Allowed,
       Pragma_External_Name_Casing,
       Pragma_Favor_Top_Level,
+      Pragma_GNAT_Annotate,
       Pragma_Ignore_Pragma,
       Pragma_Implicit_Packing,
       Pragma_Initialize_Scalars,