]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid renamed declaration becoming both ignored and checked
authorViljar Indus <indus@adacore.com>
Fri, 1 Aug 2025 10:41:24 +0000 (13:41 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 9 Sep 2025 12:39:54 +0000 (14:39 +0200)
gcc/ada/ChangeLog:

* ghost.adb (Mark_Ghost_Declaration_Or_Body): Mark ghost
entity explicitly as ignored or checked.

gcc/ada/ghost.adb

index 31d171dee00cce9e0f9d05c3374359bc3b86293d..9474beb26b2cb3bed2f6c9f11a02dd3014480a23 100644 (file)
@@ -2298,16 +2298,45 @@ package body Ghost is
       Param        : Node_Id;
       Param_Id     : Entity_Id;
 
+      procedure Mark_And_Set_Is_Checked_Ghost_Entity (E : Entity_Id);
+      --  Sets Is_Checked_Ghost_Entity, unsets Is_Ignored_Ghost_Entity
+
+      procedure Mark_And_Set_Is_Ignored_Ghost_Entity (E : Entity_Id);
+      --  Sets Is_Ignored_Ghost_Entity, unsets Is_Checked_Ghost_Entity
+
+      ------------------------------------------
+      -- Mark_And_Set_Is_Checked_Ghost_Entity --
+      ------------------------------------------
+
+      procedure Mark_And_Set_Is_Checked_Ghost_Entity (E : Entity_Id) is
+      begin
+         Set_Is_Checked_Ghost_Entity (E, True);
+         Set_Is_Ignored_Ghost_Entity (E, False);
+      end Mark_And_Set_Is_Checked_Ghost_Entity;
+
+      ------------------------------------------
+      -- Mark_And_Set_Is_Ignored_Ghost_Entity --
+      ------------------------------------------
+
+      procedure Mark_And_Set_Is_Ignored_Ghost_Entity (E : Entity_Id) is
+      begin
+         Set_Is_Checked_Ghost_Entity (E, False);
+         Set_Is_Ignored_Ghost_Entity (E, True);
+      end Mark_And_Set_Is_Ignored_Ghost_Entity;
+
+   --  Start of processing for Mark_Ghost_Declaration_Or_Body
+
    begin
       Set_Ghost_Assertion_Level (Id, Level);
 
       if Mode = Name_Check then
          Mark_Formals := True;
-         Set_Is_Checked_Ghost_Entity (Id);
+         Mark_And_Set_Is_Checked_Ghost_Entity (Id);
 
       elsif Mode = Name_Ignore then
          Mark_Formals := True;
-         Set_Is_Ignored_Ghost_Entity (Id);
+         Mark_And_Set_Is_Ignored_Ghost_Entity (Id);
+
          Set_Is_Ignored_Ghost_Node (N);
          Record_Ignored_Ghost_Node (N);
       end if;
@@ -2335,10 +2364,10 @@ package body Ghost is
             Set_Ghost_Assertion_Level (Param_Id, Level);
 
             if Mode = Name_Check then
-               Set_Is_Checked_Ghost_Entity (Param_Id);
+               Mark_And_Set_Is_Checked_Ghost_Entity (Param_Id);
 
             elsif Mode = Name_Ignore then
-               Set_Is_Ignored_Ghost_Entity (Param_Id);
+               Mark_And_Set_Is_Ignored_Ghost_Entity (Param_Id);
             end if;
 
             Next (Param);