Commit 3aba5ed5 by Ed Schonberg Committed by Arnaud Charlet

sem_type.ads, [...] (Has_Abstract_Interpretation): Make predicate recursive...

2007-04-06  Ed Schonberg  <schonberg@adacore.com>
	    Javier Miranda  <miranda@adacore.com>

	* sem_type.ads, sem_type.adb (Has_Abstract_Interpretation): Make
	predicate recursive, to handle complex expressions on literals whose
	spurious ambiguity comes from the abstract interpretation of some
	subexpression.
	(Interface_Present_In_Ancestor): Add support to concurrent record
	types.
	(Add_One_Interp,Disambiguate): Split Is_Abstract flag into
	Is_Abstract_Subprogram and Is_Abstract_Type.

From-SVN: r123598
parent 16ca248a
...@@ -375,7 +375,8 @@ package body Sem_Type is ...@@ -375,7 +375,8 @@ package body Sem_Type is
-- instance). -- instance).
elsif In_Instance elsif In_Instance
and then Is_Abstract (E) and then Is_Overloadable (E)
and then Is_Abstract_Subprogram (E)
and then not Is_Dispatching_Operation (E) and then not Is_Dispatching_Operation (E)
then then
return; return;
...@@ -1008,6 +1009,8 @@ package body Sem_Type is ...@@ -1008,6 +1009,8 @@ package body Sem_Type is
elsif Ekind (T2) = E_Class_Wide_Type then elsif Ekind (T2) = E_Class_Wide_Type then
return return
Present (Non_Limited_View (Etype (T2)))
and then
Covers (T1, Class_Wide_Type (Non_Limited_View (Etype (T2)))); Covers (T1, Class_Wide_Type (Non_Limited_View (Etype (T2))));
else else
return False; return False;
...@@ -1218,9 +1221,18 @@ package body Sem_Type is ...@@ -1218,9 +1221,18 @@ package body Sem_Type is
E : Entity_Id; E : Entity_Id;
begin begin
E := Current_Entity (N); if Nkind (N) not in N_Op
or else Ada_Version < Ada_05
or else not Is_Overloaded (N)
or else No (Universal_Interpretation (N))
then
return False;
else
E := Get_Name_Entity_Id (Chars (N));
while Present (E) loop while Present (E) loop
if Is_Abstract (E) if Is_Overloadable (E)
and then Is_Abstract_Subprogram (E)
and then Is_Numeric_Type (Etype (E)) and then Is_Numeric_Type (Etype (E))
then then
return True; return True;
...@@ -1229,7 +1241,21 @@ package body Sem_Type is ...@@ -1229,7 +1241,21 @@ package body Sem_Type is
end if; end if;
end loop; end loop;
-- Finally, if an operand of the binary operator is itself
-- an operator, recurse to see whether its own abstract
-- interpretation is responsible for the spurious ambiguity.
if Nkind (N) in N_Binary_Op then
return Has_Abstract_Interpretation (Left_Opnd (N))
or else Has_Abstract_Interpretation (Right_Opnd (N));
elsif Nkind (N) in N_Unary_Op then
return Has_Abstract_Interpretation (Right_Opnd (N));
else
return False; return False;
end if;
end if;
end Has_Abstract_Interpretation; end Has_Abstract_Interpretation;
-- Start of processing for Remove_Conversions -- Start of processing for Remove_Conversions
...@@ -1268,6 +1294,12 @@ package body Sem_Type is ...@@ -1268,6 +1294,12 @@ package body Sem_Type is
Act1 := Left_Opnd (N); Act1 := Left_Opnd (N);
Act2 := Right_Opnd (N); Act2 := Right_Opnd (N);
-- Use type of second formal, so as to include
-- exponentiation, where the exponent may be
-- ambiguous and the result non-universal.
Next_Formal (F1);
else else
return It1; return It1;
end if; end if;
...@@ -1314,12 +1346,10 @@ package body Sem_Type is ...@@ -1314,12 +1346,10 @@ package body Sem_Type is
It1 := It; It1 := It;
end if; end if;
elsif Nkind (Act1) in N_Op elsif Is_Numeric_Type (Etype (F1))
and then Is_Overloaded (Act1) and then
and then Present (Universal_Interpretation (Act1)) (Has_Abstract_Interpretation (Act1)
and then Is_Numeric_Type (Etype (F1)) or else Has_Abstract_Interpretation (Act2))
and then Ada_Version >= Ada_05
and then Has_Abstract_Interpretation (Act1)
then then
if It = Disambiguate.It1 then if It = Disambiguate.It1 then
return Disambiguate.It2; return Disambiguate.It2;
...@@ -1716,7 +1746,7 @@ package body Sem_Type is ...@@ -1716,7 +1746,7 @@ package body Sem_Type is
return It2; return It2;
end if; end if;
else else
return No_Interp; return Remove_Conversions;
end if; end if;
end; end;
...@@ -2104,6 +2134,10 @@ package body Sem_Type is ...@@ -2104,6 +2134,10 @@ package body Sem_Type is
Target_Typ := Typ; Target_Typ := Typ;
end if; end if;
if Is_Concurrent_Record_Type (Target_Typ) then
Target_Typ := Corresponding_Concurrent_Type (Target_Typ);
end if;
-- In case of concurrent types we can't use the Corresponding Record_Typ -- In case of concurrent types we can't use the Corresponding Record_Typ
-- to look for the interface because it is built by the expander (and -- to look for the interface because it is built by the expander (and
-- hence it is not always available). For this reason we traverse the -- hence it is not always available). For this reason we traverse the
...@@ -2671,16 +2705,14 @@ package body Sem_Type is ...@@ -2671,16 +2705,14 @@ package body Sem_Type is
if B1 = B2 then if B1 = B2 then
return B1; return B1;
elsif False elsif (T1 = Universal_Integer and then Is_Integer_Type (T2))
or else (T1 = Universal_Integer and then Is_Integer_Type (T2))
or else (T1 = Universal_Real and then Is_Real_Type (T2)) or else (T1 = Universal_Real and then Is_Real_Type (T2))
or else (T1 = Universal_Fixed and then Is_Fixed_Point_Type (T2)) or else (T1 = Universal_Fixed and then Is_Fixed_Point_Type (T2))
or else (T1 = Any_Fixed and then Is_Fixed_Point_Type (T2)) or else (T1 = Any_Fixed and then Is_Fixed_Point_Type (T2))
then then
return B2; return B2;
elsif False elsif (T2 = Universal_Integer and then Is_Integer_Type (T1))
or else (T2 = Universal_Integer and then Is_Integer_Type (T1))
or else (T2 = Universal_Real and then Is_Real_Type (T1)) or else (T2 = Universal_Real and then Is_Real_Type (T1))
or else (T2 = Universal_Fixed and then Is_Fixed_Point_Type (T1)) or else (T2 = Universal_Fixed and then Is_Fixed_Point_Type (T1))
or else (T2 = Any_Fixed and then Is_Fixed_Point_Type (T1)) or else (T2 = Any_Fixed and then Is_Fixed_Point_Type (T1))
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -208,7 +208,7 @@ package Sem_Type is ...@@ -208,7 +208,7 @@ package Sem_Type is
Iface : Entity_Id) return Boolean; Iface : Entity_Id) return Boolean;
-- Ada 2005 (AI-251): Typ must be a tagged record type/subtype and Iface -- Ada 2005 (AI-251): Typ must be a tagged record type/subtype and Iface
-- must be an abstract interface type. This function is used to check if -- must be an abstract interface type. This function is used to check if
-- some ancestor of Typ implements Iface. -- Typ or some ancestor of Typ implements Iface.
function Intersect_Types (L, R : Node_Id) return Entity_Id; function Intersect_Types (L, R : Node_Id) return Entity_Id;
-- Find the common interpretation to two analyzed nodes. If one of the -- Find the common interpretation to two analyzed nodes. If one of the
......
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