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 handling of controlling types


Tested on i686-linux, committed on trunk

This patch broadens the predicate that recognizes inherited operations that
require dispatching wrappers, when their controlling type is a null extension
that implements more interfaces than its parent type.

The pragma Persistent_BSS, introduced to support warm-restart procedures, is
intended to apply only to objects that have no explicit initialization. The
corresponding check was missing from the extended condition that emits the
linker directive.

The following must execute quietly.

gcc -c -S pbs.ads
grep persistent pbs.s

pragma persistent_bss;
package pbs is
    type iat is array (1 .. 10) of integer;
    ia : iat := (others => 7);
end;

Also, if all default expressions for the components of a record are compile-time
known constants, it is possible to replace the elaboration code for an object
of the type, by a static constant aggregate.

When building a reference to an entity in generated code, use New_Occurrence_Of
so that the entity is properly set on the reference. Using an unanalyzed
identifier might fail if the entity is not directly visible.

gnat.dg/aggr6.adb must compile quietly.

Finally, anonymous access components can appear in more contexts in Ada
2005. If the designated type of such an anonymous access type contains tasks,
we must create a Master_Entity for the access type at the time the enclosing
type is expanded.
This should only be done if the designated type contains tasks. This is a
worthwhile optimization, but it is also mandatory in the case of tasks with
access discriminants: without this check, the Master_Id is created when the
corresponding record is analyzed, and the task itself does not get a proper
Master entity, leading to a back-end crash.

The following must compile quietly in Ada2005 mode.

with access3;
package access4 is new access3;
generic
package access3 is
  type Object is private;
private
  type Thread;
  type Thread_Access is access Thread;

  type Object is tagged record
     Pointer : Thread_Access;
  end record;
end;

package body access3 is
  task type Thread (Disc : access Object)  is
     entry Start;
  end Thread;

  task body Thread is
  begin
     accept Start;
  end;
end T;

2007-06-06  Ed Schonberg  <schonberg@adacore.com>
	    Javier Miranda  <miranda@adacore.com>
	    Robert Dewar  <dewar@adacore.com>

	* exp_ch3.adb (Make_Controlling_Function_Wrappers): generate wrapper a
	wrapper when the full view of the controlling type of an inherited
	function that dispatches on result implements interfaces.
	(Expand_N_Object_Declaration): In cases where the type of the
	declaration is anonymous access, create finalization list for it.
	(Expand_N_Object_Declaration): Generate a persistent_bss directive only
	if the object has no explicit initialization, to match description of
	functionality of pragam Persistent_BSS.
	(Build_Equivalent_Array_Aggregate, Build_Equivalent_Record_Aggregate):
	new function to build static aggregates, to replace initialization call
	when static initialization is desired.
	(Freeze_Type): Generate a list controller for an access type whenever
	its designated type has controlled anonymous access discriminants.
	(Build_Equivalent_Aggregate): New procedure to compute a static
	aggregate to be used as default initialization for composite types,
	instead of a generating a call to the initialization procedure for the
	type.
	(Build_Initialization_Call): When available, replace a call to the
	initialization procedure with a copy of the equivalent static aggregate
	for the type.
	(Expand_N_Object_Declaration):  Use New_Occurrence_Of in generated
	declarations for objects of a class-wide interface type, rather than
	just identifiers, to prevent visibility problems.
	(Expand_N_Object_Declaration): When expanding the declaration for an
	object of a class-wide interface type, preserve the homonym chain of
	the original entity before exchanging it with that of the generated
	renaming declaration.
	(Freeze_Enumeration_Type): Don't raise CE if No_Exception_Propagation
	active, because there is no way to handle the exception.
	(Freeze_Record_Type): In case of CPP_Class types add a call to Make_DT
	to do a minimum decoration of the Access_Disp_Table list.
	(Expand_Record_Controller): Avoid the addition of the controller between
	the component containing the tag of a secondary dispatch table and its
	adjacent component that stores the offset to the base of the object.
	This latter component is only generated when the parent type has
	discriminants ---documented in Add_Interface_Tag_Components).
	(Apply_Array_Size_Check): Removed, no longer needed.
	(Expand_N_Full_Type_Declaration): If the type has anonymous access
	components, create a Master_Entity for it only if it contains tasks.
	(Build_Init_Procedure): Suppress the tag assignment compiling under
	no run-time mode.
	(Freeze_Record_Type): Remove code associated with creation of dispatch
	table.
	(Init_Secondary_Tags): Update type of actuals when generating calls to
	Ada.Tags.Set_Offset_To_Top
	(Stream_Operation_OK): Disable use of streams compiling under no
	run-time mode
	(Expand_N_Object_Declaration): Don't do Initialize_Scalars initalization
	if Has_Init_Expression set.
	(Build_Init_Procedure): Replace call to Fill_DT_Entry by call to
	Register_Primitive, which provides the same functionality.
	(Requires_Init_Proc): Return false in case of interface types.
	(Add_Secondary_Tables): Use the new attribute Related_Interface to
	cleanup the code.
	(Predefined_Primitive_Freeze): Do not assume that an internal entity
	is always associated with a predefined primitive because the internal
	entities associated with interface types are not predefined primitives.
	Therefore, the call to Is_Internal is replaced by a call to the
	function Is_Predefined_Dispatching_Operation.
	(Make_Eq_If): When generating the list of comparisons for the
	components of a given variant, omit the controller component that is
	present if the variant has controlled components.

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]