From: Viljar Indus Date: Fri, 1 Aug 2025 10:20:38 +0000 (+0300) Subject: ada: Avoid marking a ghost pragma twice X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43b631530d4e2d4be9bcebb70848aea50c535e6d;p=thirdparty%2Fgcc.git ada: Avoid marking a ghost pragma twice Previously all assertion level pragmas were marked based on the current scope. Additionally some pragmas were marked afterwards based on the relevant entity e.g. Pre. This would lead to cases where a pragma was marked as both ignored and checked ghost pragma. Each pragma should get marked only once based on their individual semantics. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): Set Mark_Ghost_Code individually based on the semantics of each pragma. --- diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 00b78d9632f..32da63fa8b4 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -8765,6 +8765,8 @@ package body Sem_Prag is Check_Arg_Is_OK_Static_Expression (Arg2, Standard_String); Analyze_And_Resolve (Arg1x, Standard_Boolean); + Mark_Ghost_Pragma (N, Current_Scope); + if CodePeer_Mode then Rewrite (N, Make_Null_Statement (Loc)); return; @@ -12749,12 +12751,6 @@ package body Sem_Prag is raise Pragma_Exit; end if; - -- Mark assertion pragmas as Ghost depending on their enclosing context - - if Assertion_Expression_Pragma (Prag_Id) then - Mark_Ghost_Pragma (N, Current_Scope); - end if; - -- Preset arguments Arg_Count := List_Length (Pragma_Argument_Associations (N)); @@ -14364,6 +14360,7 @@ package body Sem_Prag is Check_At_Most_N_Arguments (2); Gather_Associations (Names, Args); Check_Arg_Order (Names); + Mark_Ghost_Pragma (N, Current_Scope); -- Special processing for Loop_Invariant, Loop_Variant or for -- other cases where a Loop_Entry attribute is present. If the @@ -15385,6 +15382,8 @@ package body Sem_Prag is -- the mode now to ensure that any nodes generated during analysis -- and expansion are marked as Ghost. + Mark_Ghost_Pragma (N, Current_Scope); + Set_Ghost_Mode (N); GNAT_Pragma; @@ -21580,6 +21579,7 @@ package body Sem_Prag is GNAT_Pragma; Check_At_Least_N_Arguments (1); Check_Loop_Pragma_Placement; + Mark_Ghost_Pragma (N, Current_Scope); -- Process all increasing / decreasing expressions