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. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.adb (New_Copy): Reset flags related to ghost entities before marking the new node.