This is the mail archive of the gcc-patches@gcc.gnu.org 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] Fix duplicate symbol error


Tested on x86-linux, committed on mainline.

When an analyzed expression is copied and contains itypes, the copy has
to have its own local itypes, to ensure that the back-end elaborates them
in the proper scope. The new itype shares all the characteristics of the
old, and is obtained by a single copy. However, recent changes in the
back-end make the internal names of itypes meaningful, and thus it is
necessary to create a new internal name for each generated itype.

Test case (should generate no error, was generating assembler errors):
$ gcc -c bug1.ads
--
package Bug1 is

   type Pos_Array is array (Natural range <>) of Positive;

   type Pos_Access is access Pos_Array;

   Ct_Pos_Array : constant
      array (Boolean) of Pos_Access :=
      (False  => new Pos_Array'(0 => 1, 1 => 1, 2 => 2),
       True   => new Pos_Array'(0 => 1, 1 => 1));

   type Float_Array is array (Positive range <>) of Float;

   type Float_Access is access Float_Array;

   False_Last : constant Natural := Ct_Pos_Array (False)'Last;
   True_Last  : constant Natural := Ct_Pos_Array (True)'Last;

   Ct_Float_Array : constant
      array (Boolean) of Float_Access :=
      (False => new Float_Array'(1 .. False_Last => 0.0),
       True  => new Float_Array'(1 .. True_Last  => 0.0));

end;

2004-12-07  Ed Schonberg  <schonberg@adacore.com>

	* atree.adb (Visit_Itype): Create a new name for the generated itype,
	because the back-end may otherwise treat it as a redefinition of the
	old symbol.

Attachment: difs.3
Description: Text document


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