From 36d4f97d589085ddb0abccf3e0f76a3a1c8045c2 Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Wed, 17 Mar 2021 18:33:34 +0100 Subject: [PATCH] [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. --- gcc/ada/aspects.ads | 13 ++++++++++--- gcc/ada/gnat1drv.adb | 7 ------- gcc/ada/lib-writ.adb | 2 +- gcc/ada/par-prag.adb | 1 + gcc/ada/sem_ch13.adb | 3 ++- gcc/ada/sem_prag.adb | 3 ++- gcc/ada/sem_prag.ads | 1 + gcc/ada/snames.ads-tmpl | 3 ++- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads index 2cbb2da..0f9ed23 100644 --- a/gcc/ada/aspects.ads +++ b/gcc/ada/aspects.ads @@ -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, diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 59b9595..22c9311 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -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:" diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index 4dfb68e..16993dd 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -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'; diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb index d701c2c..06c7d87 100644 --- a/gcc/ada/par-prag.adb +++ b/gcc/ada/par-prag.adb @@ -1389,6 +1389,7 @@ begin | Pragma_Finalize_Storage_Only | Pragma_Ghost | Pragma_Global + | Pragma_GNAT_Annotate | Pragma_Ident | Pragma_Implementation_Defined | Pragma_Implemented diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 83d7d3c..cdc0083 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 14351b3..36b305e 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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, diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads index c620beb..e166481 100644 --- a/gcc/ada/sem_prag.ads +++ b/gcc/ada/sem_prag.ads @@ -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, diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl index b9ca607..837a878 100644 --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -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, -- 2.7.4