This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Entity names are not unique

This patch updates the Unique_Name procedure in order to prefix the
string "ada___" to child units that have a nested subprogram or package,
so that they do not clash with a parent package of the same name.

This is for GNATprove only and does not affect regular compilation.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-07-10  Simon Buist  <>


	* (Child_Prefix): New constant.
	* sem_util.adb (Unique_Name): Add a special prefix to child
	units that have a nested subprogram or package.
--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -25781,6 +25781,8 @@ package body Sem_Util is
                   end if;
+            elsif Is_Child_Unit (U) then
+               return Child_Prefix & Unique_Name (S) & "__" & This_Name;
                return Unique_Name (S) & "__" & This_Name;
             end if;

--- gcc/ada/
+++ gcc/ada/
@@ -2854,6 +2854,10 @@ package Sem_Util is
    --  Return a unique name for entity E, which could be used to identify E
    --  across compilation units.
+   Child_Prefix : constant String := "ada___";
+   --  Prefix for child packages when building a unique name for an entity. It
+   --  is included here to share between Unique_Name and gnatprove.
    function Unit_Is_Visible (U : Entity_Id) return Boolean;
    --  Determine whether a compilation unit is visible in the current context,
    --  because there is a with_clause that makes the unit available. Used to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]