[Ada] Turn GNAT_Annotate into its own pragma

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.
This commit is contained in:
Ghjuvan Lacambre 2021-03-17 18:33:34 +01:00 committed by Pierre-Marie de Rodat
parent 22c0e0cabd
commit 36d4f97d58
8 changed files with 19 additions and 14 deletions

View 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,
@ -319,6 +321,7 @@ package Aspects is
No_Duplicates_Allowed : constant array (Aspect_Id) of Boolean :=
(Aspect_Annotate => False,
Aspect_GNAT_Annotate => False,
Aspect_Test_Case => False,
others => True);
@ -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,

View 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:"

View 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';

View File

@ -1389,6 +1389,7 @@ begin
| Pragma_Finalize_Storage_Only
| Pragma_Ghost
| Pragma_Global
| Pragma_GNAT_Annotate
| Pragma_Ident
| Pragma_Implementation_Defined
| Pragma_Implemented

View 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

View 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,

View 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,

View 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,