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] fixes in attributes handling


Tested on i686-linux, committed on trunk

The use of the subprograms of Ada.Tags was not supported with abstract
interface types. This patch fixes this restriction of our implementation.
After this patch the following test program compiles and executes well.
--
with Ada.Text_IO;           use Ada.Text_IO;
with Ada.Wide_Text_IO;      use Ada.Wide_Text_IO;
with Ada.Wide_Wide_Text_IO; use Ada.Wide_Wide_Text_IO;
with Ada.Tags;              use Ada.Tags;
--
procedure Do_Test is
   package Pkg is
      type Iface is interface;
--
      type Root is tagged null record;
      type DT is new Root and Iface with null record;
   end Pkg;
   use Pkg;
--
   procedure IW_Test (O : Iface'Class) is
   begin
      Put_Line (External_Tag (O'Tag));
      Put_Line (Expanded_Name (O'Tag));
      Put_Line (Wide_Expanded_Name (O'Tag));
      Put_Line (Wide_Wide_Expanded_Name (O'Tag));
      Put_Line (External_Tag (O'Tag));
   end IW_Test;
--
   Obj1 : DT;
   Obj2 : Iface'Class := Iface'Class (Obj1);
begin
   Put_Line (External_Tag (Obj2'Tag));
   Put_Line (Expanded_Name (Obj2'Tag));
   Put_Line (Wide_Expanded_Name (Obj2'Tag));
   Put_Line (Wide_Wide_Expanded_Name (Obj2'Tag));
   Put_Line (External_Tag (Obj2'Tag));
   Ada.Text_IO.Put_Line ("-------");
   IW_Test (Obj1);
end Do_Test;
--
Command: gnatmake do_test.adb; ./do_test
Output:
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  -------
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT
  DO_TEST.PKG.DT

This patch fixes a problem with taking 'Size of packed array types,
where the back end was being asked to do this, and got confused since
it always works with the corresponding implementation type.

The fix is to have the front end return the Size when it is set by
an explicit size clause. This fixes the above bug, and is always more
efficient, since it makes such size values known at compile time.

gnat.dg/rep_problem2.adb should compile cleanly.

2007-06-06  Hristian Kirtchev  <kirtchev@adacore.com>
	    Javier Miranda  <miranda@adacore.com>
	    Robert Dewar  <dewar@adacore.com>

	* exp_attr.adb (Expand_N_Attribute_Reference): Case Callable and
	Terminated: Add unchecked type conversion from System.Address to
	System.Tasking.Task_Id when calling the predefined primitive
	_disp_get_task_id.
	Disable new Ada 05 accessibility check for JVM.NET targets, which
	cannot be implemented in a practical way.
	(Expand_N_Attribute_Reference: case Attribute_Tag): The use of 'Tag in
	the sources always references the tag of the actual object. Therefore,
	if 'Tag is applied in the sources to class-wide interface objects we
	generate code that displaces "this" to reference the base of the object.
	(Expand_N_Attribute_Reference, case Size): Return specified size if
	known to front end.
	(Expand_N_Attribute_Reference): The expansion of the 'Address attribute
	has code that displaces the pointer of the object to manage interface
	types. However this code must not be executed when the prefix is a
	subprogram. This bug caused the wrong expansion of the internally
	generated assignment that fills the dispatch table when the primitive
	is a function returning a class-wide interface type.
	(Expand_N_Attribute_Reference:Attribute_Valid): Remove incorrect call to
	Set_Attribute_Name for Name_Unaligned_Valid.

Attachment: difs
Description: Text document


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