===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1996-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -892,6 +892,27 @@
Add_Str_To_Name_Buffer (Suffix);
end if;
+ -- Add a special prefix to distinguish Ghost entities. In Ignored Ghost
+ -- mode, these entities should not leak in the "living" space and they
+ -- should be removed by the compiler in a post-processing pass. Thus,
+ -- the prefix allows anyone to check that the final executable indeed
+ -- does not contain such entities, in such a case. Do not insert this
+ -- prefix for compilation units, whose name is used as a basis for the
+ -- name of the generated elaboration procedure and (when appropriate)
+ -- the executable produced. Only insert this prefix once, for Ghost
+ -- entities declared inside other Ghost entities. Three leading
+ -- underscores are used so that "___ghost_" is a unique substring of
+ -- names produced for Ghost entities, while "__ghost_" can appear in
+ -- names of entities inside a child/local package called "Ghost".
+
+ if Is_Ghost_Entity (E)
+ and then not Is_Compilation_Unit (E)
+ and then (Name_Len < 9
+ or else Name_Buffer (1 .. 9) /= "___ghost_")
+ then
+ Insert_Str_In_Name_Buffer ("___ghost_", 1);
+ end if;
+
Name_Buffer (Name_Len + 1) := ASCII.NUL;
end Get_External_Name;
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 1996-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -76,6 +76,12 @@
-- qualification for such entities. In particular this means that direct
-- local variables of a procedure are not qualified.
+ -- For Ghost entities, the encoding adds a prefix "___ghost_" to aid the
+ -- detection of leaks of Ignored Ghost entities in the "living" space.
+ -- Ignored Ghost entities and any code associated with them should be
+ -- removed by the compiler in a post-processing pass. As a result,
+ -- object files should not contain any occurrences of this prefix.
+
-- As an example of the local name convention, consider a procedure V.W
-- with a local variable X, and a nested block Y containing an entity Z.
-- The fully qualified names of the entities X and Z are: