-- Is_Class_Wide_Type (synthesized)
-- Applies to all entities, true for class wide types and subtypes
+-- Is_Class_Wide_Wrapper
+-- Defined in subprogram entities. Indicates that it has been created as
+-- a wrapper in a generic/instance scenario involving a formal type and
+-- a generic primitive operation when the actual is a class-wide type.
+
-- Is_Compilation_Unit
-- Defined in all entities. Set if the entity is a package or subprogram
-- entity for a compilation unit other than a subunit (since we treat
-- Ignore_SPARK_Mode_Pragmas
-- Is_Abstract_Subprogram (non-generic case only)
-- Is_Called (non-generic case only)
+ -- Is_Class_Wide_Wrapper
-- Is_Constructor
-- Is_CUDA_Kernel (non-generic case only)
-- Is_DIC_Procedure (non-generic case only)
-- Default_Expressions_Processed
-- Has_Nested_Subprogram
-- Ignore_SPARK_Mode_Pragmas
+ -- Is_Class_Wide_Wrapper
-- Is_Elaboration_Checks_OK_Id
-- Is_Elaboration_Warnings_OK_Id
-- Is_Intrinsic_Subprogram
-- Is_Abstract_Subprogram (non-generic case only)
-- Is_Asynchronous
-- Is_Called (non-generic case only)
+ -- Is_Class_Wide_Wrapper
-- Is_Constructor
-- Is_CUDA_Kernel
-- Is_DIC_Procedure (non-generic case only)
Is_Checked_Ghost_Entity,
Is_Child_Unit,
Is_Class_Wide_Equivalent_Type,
+ Is_Class_Wide_Wrapper,
Is_Compilation_Unit,
Is_Completely_Hidden,
Is_Concurrent_Record_Type,
Sm (Is_Character_Type, Flag),
Sm (Is_Checked_Ghost_Entity, Flag),
Sm (Is_Child_Unit, Flag),
+ Sm (Is_Class_Wide_Wrapper, Flag),
Sm (Is_Class_Wide_Equivalent_Type, Flag),
Sm (Is_Compilation_Unit, Flag),
Sm (Is_Concurrent_Record_Type, Flag),
and then Is_Class_Wide_Type (Get_Instance_Of (Etype (Formal)))
then
Formal_Typ := Etype (Formal);
- Actual_Typ := Get_Instance_Of (Formal_Typ);
- Root_Typ := Etype (Actual_Typ);
+ Actual_Typ := Base_Type (Get_Instance_Of (Formal_Typ));
+ Root_Typ := Root_Type (Actual_Typ);
exit;
end if;
elsif CW_Prim_Op = Root_Prim_Op then
Prim_Op := Root_Prim_Op;
+ -- The two subprograms are legal but the class-wide subprogram is
+ -- a class-wide wrapper built for a previous instantiation; the
+ -- wrapper has precedence.
+
+ elsif Present (Alias (CW_Prim_Op))
+ and then Is_Class_Wide_Wrapper (Ultimate_Alias (CW_Prim_Op))
+ then
+ Prim_Op := CW_Prim_Op;
+
-- Otherwise both candidate subprograms are user-defined and
-- ambiguous.
Set_Corresponding_Body (Spec_Decl, Defining_Entity (Body_Decl));
end if;
+ Set_Is_Class_Wide_Wrapper (Wrap_Id);
+
-- If the operator carries an Eliminated pragma, indicate that the
-- wrapper is also to be eliminated, to prevent spurious error when
-- using gnatelim on programs that include box-initialization of