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] remove "with type"


Tested on i686-linux, committed on trunk

When an object declaration has an unconstrained nominal subtype, the initial
expression is used to build an actual constrained subtype for it. If the type
is limited there can be no initial expression in Ada95, and therefore limited
types with unknown discriminants do not receive an actual subtype. In Ada2005
it is possible to initialize such an object with a function call. If the
underlying type is unconstrained, we must extend this mechanism to limited
types, in order to build a constrained subtype that is usable by the back-end.

gnat.dg/test_tables.adb must now compile quietly.

If an object O is a packed component that is not directly addressable, then
a renaming of it is handled like a macro by the front-end, and replaced at
every point of use by the expression that denotes it. Such a renaming cannot
be considered free of side effects, because the value of the object may be
changed through the renaming. If the object O is itself the prefix of another
renaming, the object denoted of this later renaming can be affected accidentally
by an assignment to O.

gnat.dg/tfren.adb must execute quietly.

When a with_clause mentions a child unit, we must determine whether the parent
unit is a renaming, in order to create the proper file name for the child, using
the renamed unit as the proper parent name. The code that examines the parent
unit did not account for the case where the parent itself is a child unit, and
failed to recognize that the parent was a renaming, As a result, the file name
for the requested unit was incorrect, and the file for it was not found by the
load procedure.

The following must compile quietly:

package GNOT is
   pragma Pure;
end GNOT;

with Not_System.GNOT.Mumble;
package GNOT.Mumble renames Not_System.GNOT.Mumble;

package Not_System is
   X : Integer;
end Not_System;

package Not_System.GNOT is
   Y : Integer;
end Not_System.GNOT;

package Not_System.GNOT.Mumble is
   Z : Integer;
end Not_System.GNOT.Mumble;

package Not_System.GNOT.Mumble.Dumble is end;

with GNOT.Mumble; use GNOT.Mumble;
with GNOT.Mumble.Dumble; use GNOT.Mumble.Dumble;  --  This is legal!
procedure Main is
begin
   null;
end Main;

Finally, "with type" is a GNAT extension introduced 8 years ago, to handle
mutually recursive types declared in different compilation units. This feature
has been made obsolete by the Limited_With clause of Ada 2005, and With_Type
context clauses are now rejected by the compiler.

2007-06-06  Ed Schonberg  <schonberg@adacore.com>

	* exp_util.ads, exp_util.adb (Expand_Subtype_From_Expr): In Ada2005, an
	object of a limited type can be initialized with a call to a function
	that returns in place. If the limited type has unknown discriminants,
	and the underlying type is a constrained composite type, build an actual
	subtype from the function call, as is done for private types.
	(Side_Effect_Free): An expression that is the renaming of an object or
	whose prefix is the renaming of a object, is not side-effect free
	because it may be assigned through the renaming and its value must be
	captured in a temporary.
	(Has_Controlled_Coextensions): New routine.
	(Expand_Subtype_From_Expr): Do nothing if type is a limited interface,
	as is done for other limited types.
	(Non_Limited_Designated_Type): new predicate.
	(Make_CW_Equivalent_Type): Modified to handle class-wide interface
	objects.
	Remove all handling of with_type clauses.

        * par-ch10.adb: Remove all handling of with_type clauses.

	* lib-load.ads, lib-load.adb (Load_Main_Source): Do not get the
	checksum if the main source could not be parsed.
	(Loat_Unit): When processing a child unit, determine properly whether
	the parent unit is a renaming when the parent is itself a child unit.
	Remove handling of with_type clauses.

	* sinfo.ads, sinfo.adb (Is_Static_Coextension): New function.
	(Set_Is_Static_Coextension): New procedure.
	(Has_Local_Raise): New function
	(Set_Has_Local_Raise): New procedure
	(Renaming_Exception): New field
	(Has_Init_Expression): New flag
	(Delay_Finalize_Attach): Remove because flag is obsolete.
	(Set_Delay_Finalize_Attach): Remove because flag is obsolete.
	Remove all handling of with_type clauses.
	(Exception_Junk): Can now be set in N_Block_Statement

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]