This patch corrects a buffer issue which may lead to bogus expanded names at link time. The problem is initiated while creating the external name of a tagged type whose scope is an overloaded name. This places useless data in the Homonym_Numbers buffer which is then reused when building the qualified name of an arbitrary entity.
Tested on x86_64-pc-linux-gnu, committed on trunk 2011-12-02 Hristian Kirtchev <kirtc...@adacore.com> * exp_dbug.adb: Comment reformatting. (Get_External_Name): Use Reset_Buffers to reset the contents of Name_Buffer and Homonym_Numbers. (Qualify_All_Entity_Names): Reset the contents of Name_Buffer and Homonym_Numbers before creating a new qualified name for a particular entity. (Reset_Buffers): New routine.
Index: exp_dbug.adb =================================================================== --- exp_dbug.adb (revision 181910) +++ exp_dbug.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1996-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1996-2011, 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- -- @@ -105,11 +105,11 @@ -- Homonym_Suffix -- -------------------- - -- The string defined here (and its associated length) is used to - -- gather the homonym string that will be appended to Name_Buffer - -- when the name is complete. Strip_Suffixes appends to this string - -- as does Append_Homonym_Number, and Output_Homonym_Numbers_Suffix - -- appends the string to the end of Name_Buffer. + -- The string defined here (and its associated length) is used to gather + -- the homonym string that will be appended to Name_Buffer when the name + -- is complete. Strip_Suffixes appends to this string as does + -- Append_Homonym_Number, and Output_Homonym_Numbers_Suffix appends the + -- string to the end of Name_Buffer. Homonym_Numbers : String (1 .. 256); Homonym_Len : Natural := 0; @@ -147,6 +147,10 @@ -- If not already done, replaces the Chars field of the given entity -- with the appropriate fully qualified name. + procedure Reset_Buffers; + -- Reset the contents of Name_Buffer and Homonym_Numbers by setting their + -- respective lengths to zero. + procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean); -- Given an qualified entity name in Name_Buffer, remove any plain X or -- X{nb} qualification suffix. The contents of Name_Buffer is not changed @@ -701,8 +705,7 @@ -- Start of processing for Get_External_Name begin - Name_Len := 0; - Homonym_Len := 0; + Reset_Buffers; -- If this is a child unit, we want the child @@ -1022,6 +1025,7 @@ begin for J in Name_Qualify_Units.First .. Name_Qualify_Units.Last loop E := Defining_Entity (Name_Qualify_Units.Table (J)); + Reset_Buffers; Qualify_Entity_Name (E); -- Normally entities in the qualification list are scopes, but in the @@ -1033,6 +1037,7 @@ if Ekind (E) /= E_Variable then Ent := First_Entity (E); while Present (Ent) loop + Reset_Buffers; Qualify_Entity_Name (Ent); Next_Entity (Ent); @@ -1101,10 +1106,10 @@ if No (E) then return; - -- If this we are qualifying entities local to a generic - -- instance, use the name of the original instantiation, - -- not that of the anonymous subprogram in the wrapper - -- package, so that gdb doesn't have to know about these. + -- If this we are qualifying entities local to a generic instance, + -- use the name of the original instantiation, not that of the + -- anonymous subprogram in the wrapper package, so that gdb doesn't + -- have to know about these. elsif Is_Generic_Instance (E) and then Is_Subprogram (E) @@ -1394,6 +1399,16 @@ Name_Qualify_Units.Append (N); end Qualify_Entity_Names; + ------------------- + -- Reset_Buffers -- + ------------------- + + procedure Reset_Buffers is + begin + Name_Len := 0; + Homonym_Len := 0; + end Reset_Buffers; + -------------------- -- Strip_Suffixes -- --------------------