sem_ch3.ads, [...] (Analyze_Object_Declaration): Go to the underlying type to check if a type is Constrained in cases related to...

2005-09-01  Cyrille Comar  <comar@adacore.com>
	    Gary Dismukes  <dismukes@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>
	    Javier Miranda  <miranda@adacore.com>

	* sem_ch3.ads, sem_ch3.adb (Analyze_Object_Declaration): Go to the
	underlying type
	to check if a type is Constrained in cases related to code generation
	(rather than semantic checking) since otherwise we do not generate
	similar code for mutable private types depending if their
	discriminants are visible or not.
	(Check_Abstract_Overriding): Do not complain about failure to override
	the primitive operations used in dispatching selects since they will
	always be overriden at the freeze point of the type.
	(Access_Definition): Separate out handling for resetting the scope
	of an anonymous access function result type. Retrieve the scope
	of the associated function rather than using Current_Scope, which
	does not have a consistent value (depends on whether we're in the
	middle of analyzing formal parameters). Add ??? comment about
	finding a cleaner way to handle the special cases of scope setting.
	(Process_Incomplete_Dependents): A protected operation is never a
	dispatching operation (only its wrapper may be).
	(Build_Derived_Record_Type): In case of tagged private types that
	implement interfaces add derivation of predefined primitive
	operations.
	(Derive_Subprograms): Replace the Is_Interface_Derivation parameter
	by two parameters that are used in case of derivation from abstract
	interface types: No_Predefined_Prims is used to avoid the derivation
	of predefined primitives from the interface, and Predefined
	Prims_Only is used to complete the derivation predefined primitives
	in case of private tagged types implementing interfaces.
	Fix typo in comments
	(Find_Interface_In_Descendant): Protect the frontend against
	wrong code with large circularity chains.
	(Is_Private_Overriding): Add support for entities overriding interface
	subprograms. The test failed because Entities associated with overriden
	interface subprograms are always marked as hidden (and used to build
	the secondary dispatch table); in this case the overriden entity is
	available through the field abstract_interface_alias (cf. override_
	dispatching_operation)
	(Access_Definition): Set the scope of the type to Current_Scope for the
	case of a function with an anonymous access result type.
	(Access_Subprogram_Declaration): Handle creation of the type entity for
	an access-to-function type with an anonymous access result.
	(Check_Anonymous_Access_Types): Change Subtype_Mark to Result_Definition
	in handling for N_Access_Function_Definition.
	(Analyze_Subtype_Declaration): Modify the text of error message.
	(Derived_Type_Declaration): Modify the text of error message.
	(Process_Subtype): Modify the text of error message plus cleanup
	of one redundant error message.
	(Analyze_Component_Declaration): Code cleanup.
	(Analyze_Object_Declaration): Code cleanup.
	(Analyze_Subtype_Declaration): Propagate the null-exclusion
	attribute in case of access types. Code cleanup.
	(Array_Type_Declaration): Code cleanup.
	(Process_Discriminants): Create the new null-excluding itype
	if required. Code cleanup.
	(Process_Subtype): Create the new null-excluding itype if
	required. Code cleanup.
	(Build_Derived_Record_Type): Code cleanup to avoid calling
	twice the subprogram derive_subprograms in case of private
	types that implement interfaces. In this particular case the
	subprogram Complete_Subprograms_Derivation already does the
	job associated with the second call.

        * exp_strm.adb (Build_Elementary_Input_Call): Add an explicit
        conversion to the full view when generating an operation for a
        discriminant whose type may currently be private.

From-SVN: r103881
This commit is contained in:
Cyrille Comar 2005-09-05 10:00:11 +02:00 committed by Arnaud Charlet
parent 27e6455d37
commit 9dfd2ff8dc
3 changed files with 541 additions and 338 deletions

View File

@ -26,7 +26,6 @@
with Atree; use Atree;
with Einfo; use Einfo;
with Exp_Tss; use Exp_Tss;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
@ -594,19 +593,25 @@ package body Exp_Strm is
-- to the actual type of the prefix. If the target is a discriminant,
-- and we are in the body of the default implementation of a 'Read
-- attribute, set target type to force a constraint check (13.13.2(35)).
-- If the type of the discriminant is currently private, add another
-- unchecked conversion from the full view.
if Nkind (Targ) = N_Identifier
and then Is_Internal_Name (Chars (Targ))
and then Is_TSS (Scope (Entity (Targ)), TSS_Stream_Read)
then
Res :=
Unchecked_Convert_To (Base_Type (P_Type),
Unchecked_Convert_To (Base_Type (U_Type),
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (Lib_RE), Loc),
Parameter_Associations => New_List (
Relocate_Node (Strm))));
Set_Do_Range_Check (Res);
if Base_Type (P_Type) /= Base_Type (U_Type) then
Res := Unchecked_Convert_To (Base_Type (P_Type), Res);
end if;
return Res;
else
@ -1327,7 +1332,7 @@ package body Exp_Strm is
return
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Stream_Base_Type (Etype (C)), Loc),
New_Occurrence_Of (Field_Typ, Loc),
Attribute_Name => Nam,
Expressions => New_List (
Make_Identifier (Loc, Name_S),
@ -1490,7 +1495,7 @@ package body Exp_Strm is
Subtype_Mark => New_Reference_To (
Class_Wide_Type (RTE (RE_Root_Stream_Type)), Loc)))),
Subtype_Mark => New_Occurrence_Of (Typ, Loc));
Result_Definition => New_Occurrence_Of (Typ, Loc));
Decl :=
Make_Subprogram_Body (Loc,

File diff suppressed because it is too large Load Diff

View File

@ -98,11 +98,11 @@ package Sem_Ch3 is
-- declaration.
procedure Derive_Subprogram
(New_Subp : in out Entity_Id;
Parent_Subp : Entity_Id;
Derived_Type : Entity_Id;
Parent_Type : Entity_Id;
Actual_Subp : Entity_Id := Empty);
(New_Subp : in out Entity_Id;
Parent_Subp : Entity_Id;
Derived_Type : Entity_Id;
Parent_Type : Entity_Id;
Actual_Subp : Entity_Id := Empty);
-- Derive the subprogram Parent_Subp from Parent_Type, and replace the
-- subsidiary subtypes with the derived type to build the specification
-- of the inherited subprogram (returned in New_Subp). For tagged types,
@ -111,17 +111,25 @@ package Sem_Ch3 is
-- subprogram of the parent type.
procedure Derive_Subprograms
(Parent_Type : Entity_Id;
Derived_Type : Entity_Id;
Generic_Actual : Entity_Id := Empty;
Is_Interface_Derivation : Boolean := False);
(Parent_Type : Entity_Id;
Derived_Type : Entity_Id;
Generic_Actual : Entity_Id := Empty;
No_Predefined_Prims : Boolean := False;
Predefined_Prims_Only : Boolean := False);
-- To complete type derivation, collect/retrieve the primitive operations
-- of the parent type, and replace the subsidiary subtypes with the derived
-- type, to build the specs of the inherited ops. For generic actuals, the
-- mapping of the primitive operations to those of the parent type is also
-- done by rederiving the operations within the instance. For tagged types,
-- the derived subprograms are aliased to those of the actual, not those of
-- the ancestor.
-- the ancestor. The last two params are used in case of derivation from
-- abstract interface types: No_Predefined_Prims is used to avoid the
-- derivation of predefined primitives from the interface, and Predefined
-- Prims_Only is used to complete the derivation predefined primitives
-- in case of private tagged types implementing interfaces.
--
-- Note: one might expect this to be private to the package body, but
-- there is one rather unusual usage in package Exp_Dist.
function Find_Type_Of_Subtype_Indic (S : Node_Id) return Entity_Id;
-- Given a subtype indication S (which is really an N_Subtype_Indication