[Ada] Fix spurious errors on ghost code in generics
authorYannick Moy <moy@adacore.com>
Mon, 16 May 2022 07:58:18 +0000 (09:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 2 Jun 2022 09:06:42 +0000 (09:06 +0000)
After the recent fix for detecting illegal use of ghost entities in
code, spurious errors could be raised on generic code with ghost, due to
wrong setting of the ghost flags on copied entities from the generic to
the instantiation.

gcc/ada/

* atree.adb (New_Copy): Reset flags related to ghost entities
before marking the new node.

gcc/ada/atree.adb

index a949761..2d7962c 100644 (file)
@@ -1775,6 +1775,11 @@ package body Atree is
 
          --  Mark the copy as Ghost depending on the current Ghost region
 
+         if Nkind (New_Id) in N_Entity then
+            Set_Is_Checked_Ghost_Entity (New_Id, False);
+            Set_Is_Ignored_Ghost_Entity (New_Id, False);
+         end if;
+
          Mark_New_Ghost_Node (New_Id);
 
          New_Node_Debugging_Output (New_Id);