Commit 21ff92b4 by Ed Schonberg Committed by Arnaud Charlet

sem_type.adb (Covers): Verify that Corresponding_Record_Type is present before…

sem_type.adb (Covers): Verify that Corresponding_Record_Type is present before checking whether an...

2005-07-04  Ed Schonberg  <schonberg@adacore.com>

	* sem_type.adb (Covers): Verify that Corresponding_Record_Type is
	present before checking whether an interface type covers a synchronized
	type.

From-SVN: r101591
parent 16397eff
...@@ -613,9 +613,9 @@ package body Sem_Type is ...@@ -613,9 +613,9 @@ package body Sem_Type is
-- Start of processing for Covers -- Start of processing for Covers
begin begin
-- If either operand missing, then this is an error, but ignore -- If either operand missing, then this is an error, but ignore it (and
-- it (and pretend we have a cover) if errors already detected, -- pretend we have a cover) if errors already detected, since this may
-- since this may simply mean we have malformed trees. -- simply mean we have malformed trees.
if No (T1) or else No (T2) then if No (T1) or else No (T2) then
if Total_Errors_Detected /= 0 then if Total_Errors_Detected /= 0 then
...@@ -763,8 +763,8 @@ package body Sem_Type is ...@@ -763,8 +763,8 @@ package body Sem_Type is
then then
return True; return True;
-- If the expected type is an anonymous access, the designated -- If the expected type is an anonymous access, the designated type must
-- type must cover that of the expression. -- cover that of the expression.
elsif Ekind (T1) = E_Anonymous_Access_Type elsif Ekind (T1) = E_Anonymous_Access_Type
and then Is_Access_Type (T2) and then Is_Access_Type (T2)
...@@ -852,8 +852,8 @@ package body Sem_Type is ...@@ -852,8 +852,8 @@ package body Sem_Type is
(From_With_Type (Designated_Type (T1)) (From_With_Type (Designated_Type (T1))
and then Covers (Designated_Type (T2), Designated_Type (T1))); and then Covers (Designated_Type (T2), Designated_Type (T1)));
-- A boolean operation on integer literals is compatible with a -- A boolean operation on integer literals is compatible with modular
-- modular context. -- context.
elsif T2 = Any_Modular elsif T2 = Any_Modular
and then Is_Modular_Integer_Type (T1) and then Is_Modular_Integer_Type (T1)
...@@ -865,10 +865,10 @@ package body Sem_Type is ...@@ -865,10 +865,10 @@ package body Sem_Type is
elsif Base_Type (T2) = Any_Type then elsif Base_Type (T2) = Any_Type then
return True; return True;
-- A packed array type covers its corresponding non-packed type. -- A packed array type covers its corresponding non-packed type. This is
-- This is not legitimate Ada, but allows the omission of a number -- not legitimate Ada, but allows the omission of a number of otherwise
-- of otherwise useless unchecked conversions, and since this can -- useless unchecked conversions, and since this can only arise in
-- only arise in (known correct) expanded code, no harm is done -- (known correct) expanded code, no harm is done
elsif Is_Array_Type (T2) elsif Is_Array_Type (T2)
and then Is_Packed (T2) and then Is_Packed (T2)
...@@ -964,14 +964,14 @@ package body Sem_Type is ...@@ -964,14 +964,14 @@ package body Sem_Type is
User_Subp : Entity_Id; User_Subp : Entity_Id;
function Inherited_From_Actual (S : Entity_Id) return Boolean; function Inherited_From_Actual (S : Entity_Id) return Boolean;
-- Determine whether one of the candidates is an operation inherited -- Determine whether one of the candidates is an operation inherited by
-- by a type that is derived from an actual in an instantiation. -- a type that is derived from an actual in an instantiation.
function Is_Actual_Subprogram (S : Entity_Id) return Boolean; function Is_Actual_Subprogram (S : Entity_Id) return Boolean;
-- Determine whether a subprogram is an actual in an enclosing -- Determine whether a subprogram is an actual in an enclosing instance.
-- instance. An overloading between such a subprogram and one -- An overloading between such a subprogram and one declared outside the
-- declared outside the instance is resolved in favor of the first, -- instance is resolved in favor of the first, because it resolved in
-- because it resolved in the generic. -- the generic.
function Matches (Actual, Formal : Node_Id) return Boolean; function Matches (Actual, Formal : Node_Id) return Boolean;
-- Look for exact type match in an instance, to remove spurious -- Look for exact type match in an instance, to remove spurious
...@@ -981,16 +981,16 @@ package body Sem_Type is ...@@ -981,16 +981,16 @@ package body Sem_Type is
-- Comment required ??? -- Comment required ???
function Remove_Conversions return Interp; function Remove_Conversions return Interp;
-- Last chance for pathological cases involving comparisons on -- Last chance for pathological cases involving comparisons on literals,
-- literals, and user overloadings of the same operator. Such -- and user overloadings of the same operator. Such pathologies have
-- pathologies have been removed from the ACVC, but still appear in -- been removed from the ACVC, but still appear in two DEC tests, with
-- two DEC tests, with the following notable quote from Ben Brosgol: -- the following notable quote from Ben Brosgol:
-- --
-- [Note: I disclaim all credit/responsibility/blame for coming up with -- [Note: I disclaim all credit/responsibility/blame for coming up with
-- this example; Robert Dewar brought it to our attention, since it -- this example; Robert Dewar brought it to our attention, since it is
-- is apparently found in the ACVC 1.5. I did not attempt to find -- apparently found in the ACVC 1.5. I did not attempt to find the
-- the reason in the Reference Manual that makes the example legal, -- reason in the Reference Manual that makes the example legal, since I
-- since I was too nauseated by it to want to pursue it further.] -- was too nauseated by it to want to pursue it further.]
-- --
-- Accordingly, this is not a fully recursive solution, but it handles -- Accordingly, this is not a fully recursive solution, but it handles
-- DEC tests c460vsa, c460vsb. It also handles ai00136a, which pushes -- DEC tests c460vsa, c460vsb. It also handles ai00136a, which pushes
...@@ -1102,9 +1102,9 @@ package body Sem_Type is ...@@ -1102,9 +1102,9 @@ package body Sem_Type is
and then Etype (F1) = Standard_Boolean and then Etype (F1) = Standard_Boolean
then then
-- If the two candidates are the original ones, the -- If the two candidates are the original ones, the
-- ambiguity is real. Otherwise keep the original, -- ambiguity is real. Otherwise keep the original, further
-- further calls to Disambiguate will take care of -- calls to Disambiguate will take care of others in the
-- others in the list of candidates. -- list of candidates.
if It1 /= No_Interp then if It1 /= No_Interp then
if It = Disambiguate.It1 if It = Disambiguate.It1
...@@ -1142,9 +1142,9 @@ package body Sem_Type is ...@@ -1142,9 +1142,9 @@ package body Sem_Type is
Get_Next_Interp (I, It); Get_Next_Interp (I, It);
end loop; end loop;
-- After some error, a formal may have Any_Type and yield -- After some error, a formal may have Any_Type and yield a spurious
-- a spurious match. To avoid cascaded errors if possible, -- match. To avoid cascaded errors if possible, check for such a
-- check for such a formal in either candidate. -- formal in either candidate.
if Serious_Errors_Detected > 0 then if Serious_Errors_Detected > 0 then
declare declare
...@@ -1269,9 +1269,9 @@ package body Sem_Type is ...@@ -1269,9 +1269,9 @@ package body Sem_Type is
elsif Chars (Nam1) /= Name_Op_Not elsif Chars (Nam1) /= Name_Op_Not
and then (Typ = Standard_Boolean or else Typ = Any_Boolean) and then (Typ = Standard_Boolean or else Typ = Any_Boolean)
then then
-- Equality or comparison operation. Choose predefined operator -- Equality or comparison operation. Choose predefined operator if
-- if arguments are universal. The node may be an operator, a -- arguments are universal. The node may be an operator, name, or
-- name, or a function call, so unpack arguments accordingly. -- a function call, so unpack arguments accordingly.
declare declare
Arg1, Arg2 : Node_Id; Arg1, Arg2 : Node_Id;
...@@ -1345,10 +1345,10 @@ package body Sem_Type is ...@@ -1345,10 +1345,10 @@ package body Sem_Type is
end if; end if;
-- If the ambiguity occurs within an instance, it is due to several -- If the ambiguity occurs within an instance, it is due to several
-- formal types with the same actual. Look for an exact match -- formal types with the same actual. Look for an exact match between
-- between the types of the formals of the overloadable entities, -- the types of the formals of the overloadable entities, and the
-- and the actuals in the call, to recover the unambiguous match -- actuals in the call, to recover the unambiguous match in the
-- in the original generic. -- original generic.
-- The ambiguity can also be due to an overloading between a formal -- The ambiguity can also be due to an overloading between a formal
-- subprogram and a subprogram declared outside the generic. If the -- subprogram and a subprogram declared outside the generic. If the
...@@ -1456,9 +1456,9 @@ package body Sem_Type is ...@@ -1456,9 +1456,9 @@ package body Sem_Type is
return It2; return It2;
end if; end if;
-- Otherwise, the predefined operator has precedence, or if the -- Otherwise, the predefined operator has precedence, or if the user-
-- user-defined operation is directly visible we have a true ambiguity. -- defined operation is directly visible we have a true ambiguity. If
-- If this is a fixed-point multiplication and division in Ada83 mode, -- this is a fixed-point multiplication and division in Ada83 mode,
-- exclude the universal_fixed operator, which often causes ambiguities -- exclude the universal_fixed operator, which often causes ambiguities
-- in legacy code. -- in legacy code.
...@@ -1506,8 +1506,8 @@ package body Sem_Type is ...@@ -1506,8 +1506,8 @@ package body Sem_Type is
function Entity_Matches_Spec (Old_S, New_S : Entity_Id) return Boolean is function Entity_Matches_Spec (Old_S, New_S : Entity_Id) return Boolean is
begin begin
-- Simple case: same entity kinds, type conformance is required. -- Simple case: same entity kinds, type conformance is required. A
-- A parameterless function can also rename a literal. -- parameterless function can also rename a literal.
if Ekind (Old_S) = Ekind (New_S) if Ekind (Old_S) = Ekind (New_S)
or else (Ekind (New_S) = E_Function or else (Ekind (New_S) = E_Function
...@@ -1573,8 +1573,8 @@ package body Sem_Type is ...@@ -1573,8 +1573,8 @@ package body Sem_Type is
null; null;
end if; end if;
-- If one of the operands is Universal_Fixed, the type of the -- If one of the operands is Universal_Fixed, the type of the other
-- other operand provides the context. -- operand provides the context.
if Etype (R) = Universal_Fixed then if Etype (R) = Universal_Fixed then
return T; return T;
...@@ -1683,10 +1683,13 @@ package body Sem_Type is ...@@ -1683,10 +1683,13 @@ package body Sem_Type is
return return
Covers (Typ, Etype (N)) Covers (Typ, Etype (N))
-- Ada 2005 (AI-345) -- Ada 2005 (AI-345) The context may be a synchronized interface.
-- If the type is already frozen use the corresponding_record
-- to check whether it is a proper descendant.
or else or else
(Is_Concurrent_Type (Etype (N)) (Is_Concurrent_Type (Etype (N))
and then Present (Corresponding_Record_Type (Etype (N)))
and then Covers (Typ, Corresponding_Record_Type (Etype (N)))) and then Covers (Typ, Corresponding_Record_Type (Etype (N))))
or else or else
...@@ -1741,7 +1744,6 @@ package body Sem_Type is ...@@ -1741,7 +1744,6 @@ package body Sem_Type is
function Hides_Op (F : Entity_Id; Op : Entity_Id) return Boolean is function Hides_Op (F : Entity_Id; Op : Entity_Id) return Boolean is
Btyp : constant Entity_Id := Base_Type (Etype (First_Formal (F))); Btyp : constant Entity_Id := Base_Type (Etype (First_Formal (F)));
begin begin
return Operator_Matches_Spec (Op, F) return Operator_Matches_Spec (Op, F)
and then (In_Open_Scopes (Scope (F)) and then (In_Open_Scopes (Scope (F))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment