Commit 780d052e by Robert Dewar Committed by Arnaud Charlet

sem_ch8.adb: Minor code reorganization, comment updates.

2011-08-02  Robert Dewar  <dewar@adacore.com>

	* sem_ch8.adb: Minor code reorganization, comment updates.

2011-08-02  Robert Dewar  <dewar@adacore.com>

	* sem_res.adb (Matching_Static_Array_Bounds): Moved to Sem_Util
	* sem_util.ads, sem_util.adb (Matching_Static_Array_Bounds): Moved
	here from Sem_Res.
	(Matching_Static_Array_Bounds): Use Is_Ok_Static_Expression
	(Matching_Static_Array_Bounds): Moved here from Sem_Res

From-SVN: r177091
parent 29efbb8c
2011-08-02 Robert Dewar <dewar@adacore.com>
* sem_ch8.adb: Minor code reorganization, comment updates.
2011-08-02 Robert Dewar <dewar@adacore.com>
* sem_res.adb (Matching_Static_Array_Bounds): Moved to Sem_Util
* sem_util.ads, sem_util.adb (Matching_Static_Array_Bounds): Moved
here from Sem_Res.
(Matching_Static_Array_Bounds): Use Is_Ok_Static_Expression
(Matching_Static_Array_Bounds): Moved here from Sem_Res
2011-08-02 Ed Schonberg <schonberg@adacore.com> 2011-08-02 Ed Schonberg <schonberg@adacore.com>
* atree.h, atree.ads, atree.adb: New subprograms to manipulate Elist5. * atree.h, atree.ads, atree.adb: New subprograms to manipulate Elist5.
......
...@@ -2679,9 +2679,13 @@ package body Sem_Ch8 is ...@@ -2679,9 +2679,13 @@ package body Sem_Ch8 is
Chain_Use_Clause (N); Chain_Use_Clause (N);
end if; end if;
-- Commented needed??? -- If the Used_Operations list is already initialized, the clause has
-- been analyzed previously, and it is begin reinstalled, for example
-- when the clause appears in a package spec and we are compiling the
-- corresponding package body. In that case, make the entities on the
-- existing list use-visible.
if Used_Operations (N) /= No_Elist then if Present (Used_Operations (N)) then
declare declare
Elmt : Elmt_Id; Elmt : Elmt_Id;
begin begin
...@@ -2695,6 +2699,9 @@ package body Sem_Ch8 is ...@@ -2695,6 +2699,9 @@ package body Sem_Ch8 is
return; return;
end if; end if;
-- Otherwise, create new list and attach to it the operations that
-- are made use-visible by the clause.
Set_Used_Operations (N, New_Elmt_List); Set_Used_Operations (N, New_Elmt_List);
Id := First (Subtype_Marks (N)); Id := First (Subtype_Marks (N));
while Present (Id) loop while Present (Id) loop
......
...@@ -92,12 +92,6 @@ package body Sem_Res is ...@@ -92,12 +92,6 @@ package body Sem_Res is
-- Note that Resolve_Attribute is separated off in Sem_Attr -- Note that Resolve_Attribute is separated off in Sem_Attr
function Matching_Static_Array_Bounds
(L_Typ : Node_Id;
R_Typ : Node_Id) return Boolean;
-- L_Typ and R_Typ are two array types. Returns True when they have the
-- same dimension, and, for each index position, the same static bounds.
function Bad_Unordered_Enumeration_Reference function Bad_Unordered_Enumeration_Reference
(N : Node_Id; (N : Node_Id;
T : Entity_Id) return Boolean; T : Entity_Id) return Boolean;
...@@ -1577,65 +1571,6 @@ package body Sem_Res is ...@@ -1577,65 +1571,6 @@ package body Sem_Res is
end if; end if;
end Make_Call_Into_Operator; end Make_Call_Into_Operator;
----------------------------------
-- Matching_Static_Array_Bounds --
----------------------------------
function Matching_Static_Array_Bounds
(L_Typ : Node_Id;
R_Typ : Node_Id) return Boolean
is
L_Ndims : constant Nat := Number_Dimensions (L_Typ);
R_Ndims : constant Nat := Number_Dimensions (R_Typ);
L_Index : Node_Id;
R_Index : Node_Id;
L_Low : Node_Id;
L_High : Node_Id;
R_Low : Node_Id;
R_High : Node_Id;
begin
if L_Ndims /= R_Ndims then
return False;
end if;
-- Unconstrained types do not have static bounds
if not Is_Constrained (L_Typ) or else not Is_Constrained (R_Typ) then
return False;
end if;
L_Index := First_Index (L_Typ);
R_Index := First_Index (R_Typ);
for Indx in 1 .. L_Ndims loop
Get_Index_Bounds (L_Index, L_Low, L_High);
Get_Index_Bounds (R_Index, R_Low, R_High);
if True
and then Is_Static_Expression (L_Low)
and then Is_Static_Expression (L_High)
and then Is_Static_Expression (R_Low)
and then Is_Static_Expression (R_High)
and then Expr_Value (L_Low) = Expr_Value (R_Low)
and then Expr_Value (L_High) = Expr_Value (R_High)
then
-- Matching so far, continue with next index
null;
else
return False;
end if;
Next (L_Index);
Next (R_Index);
end loop;
return True;
end Matching_Static_Array_Bounds;
------------------- -------------------
-- Operator_Kind -- -- Operator_Kind --
------------------- -------------------
...@@ -3634,15 +3569,16 @@ package body Sem_Res is ...@@ -3634,15 +3569,16 @@ package body Sem_Res is
Operand : constant Node_Id := Expression (A); Operand : constant Node_Id := Expression (A);
Operand_Typ : constant Entity_Id := Etype (Operand); Operand_Typ : constant Entity_Id := Etype (Operand);
Target_Typ : constant Entity_Id := A_Typ; Target_Typ : constant Entity_Id := A_Typ;
begin begin
if not (Is_Tagged_Type (Target_Typ) if not (Is_Tagged_Type (Target_Typ)
and then not Is_Class_Wide_Type (Target_Typ) and then not Is_Class_Wide_Type (Target_Typ)
and then Is_Tagged_Type (Operand_Typ) and then Is_Tagged_Type (Operand_Typ)
and then not Is_Class_Wide_Type (Operand_Typ) and then not Is_Class_Wide_Type (Operand_Typ)
and then Is_Ancestor (Target_Typ, Operand_Typ)) and then Is_Ancestor (Target_Typ, Operand_Typ))
then then
Error_Msg_F ("|~~ancestor conversion is the only " Error_Msg_F ("|~~ancestor conversion is the only "
& "view conversion", A); & "permitted view conversion", A);
end if; end if;
end; end;
end if; end if;
...@@ -4893,7 +4829,7 @@ package body Sem_Res is ...@@ -4893,7 +4829,7 @@ package body Sem_Res is
if Formal_Verification_Mode if Formal_Verification_Mode
and then (Is_Fixed_Point_Type (Etype (L)) and then (Is_Fixed_Point_Type (Etype (L))
or else Is_Fixed_Point_Type (Etype (R))) or else Is_Fixed_Point_Type (Etype (R)))
and then Nkind_In (N, N_Op_Multiply, N_Op_Divide) and then Nkind_In (N, N_Op_Multiply, N_Op_Divide)
and then and then
not Nkind_In (Parent (N), N_Qualified_Expression, N_Type_Conversion) not Nkind_In (Parent (N), N_Qualified_Expression, N_Type_Conversion)
...@@ -4921,10 +4857,10 @@ package body Sem_Res is ...@@ -4921,10 +4857,10 @@ package body Sem_Res is
if Compile_Time_Known_Value (Rop) if Compile_Time_Known_Value (Rop)
and then ((Is_Integer_Type (Etype (Rop)) and then ((Is_Integer_Type (Etype (Rop))
and then Expr_Value (Rop) = Uint_0) and then Expr_Value (Rop) = Uint_0)
or else or else
(Is_Real_Type (Etype (Rop)) (Is_Real_Type (Etype (Rop))
and then Expr_Value_R (Rop) = Ureal_0)) and then Expr_Value_R (Rop) = Ureal_0))
then then
-- Specialize the warning message according to the operation -- Specialize the warning message according to the operation
...@@ -5911,7 +5847,8 @@ package body Sem_Res is ...@@ -5911,7 +5847,8 @@ package body Sem_Res is
and then Base_Type (T) /= Standard_String and then Base_Type (T) /= Standard_String
then then
Error_Msg_F Error_Msg_F
("|~~comparison is not defined on array type except String", N); ("|~~comparison is not defined on array types " &
"other than String", N);
end if; end if;
end if; end if;
......
...@@ -7998,6 +7998,62 @@ package body Sem_Util is ...@@ -7998,6 +7998,62 @@ package body Sem_Util is
return N; return N;
end Last_Source_Statement; end Last_Source_Statement;
----------------------------------
-- Matching_Static_Array_Bounds --
----------------------------------
function Matching_Static_Array_Bounds
(L_Typ : Node_Id;
R_Typ : Node_Id) return Boolean
is
L_Ndims : constant Nat := Number_Dimensions (L_Typ);
R_Ndims : constant Nat := Number_Dimensions (R_Typ);
L_Index : Node_Id;
R_Index : Node_Id;
L_Low : Node_Id;
L_High : Node_Id;
R_Low : Node_Id;
R_High : Node_Id;
begin
if L_Ndims /= R_Ndims then
return False;
end if;
-- Unconstrained types do not have static bounds
if not Is_Constrained (L_Typ) or else not Is_Constrained (R_Typ) then
return False;
end if;
L_Index := First_Index (L_Typ);
R_Index := First_Index (R_Typ);
for Indx in 1 .. L_Ndims loop
Get_Index_Bounds (L_Index, L_Low, L_High);
Get_Index_Bounds (R_Index, R_Low, R_High);
if Is_OK_Static_Expression (L_Low)
and then Is_OK_Static_Expression (L_High)
and then Is_OK_Static_Expression (R_Low)
and then Is_OK_Static_Expression (R_High)
and then Expr_Value (L_Low) = Expr_Value (R_Low)
and then Expr_Value (L_High) = Expr_Value (R_High)
then
Next (L_Index);
Next (R_Index);
else
return False;
end if;
end loop;
-- If we fall through the loop, all indexes matched
return True;
end Matching_Static_Array_Bounds;
------------------- -------------------
-- May_Be_Lvalue -- -- May_Be_Lvalue --
------------------- -------------------
......
...@@ -939,6 +939,13 @@ package Sem_Util is ...@@ -939,6 +939,13 @@ package Sem_Util is
-- See Sinfo. We rename Make_Return_Statement to the correct Ada 2005 -- See Sinfo. We rename Make_Return_Statement to the correct Ada 2005
-- terminology here. Clients should use Make_Simple_Return_Statement. -- terminology here. Clients should use Make_Simple_Return_Statement.
function Matching_Static_Array_Bounds
(L_Typ : Node_Id;
R_Typ : Node_Id) return Boolean;
-- L_Typ and R_Typ are two array types. Returns True when they have the
-- same number of dimensions, and the same static bounds for each index
-- position.
Make_Return_Statement : constant := -2 ** 33; Make_Return_Statement : constant := -2 ** 33;
-- Attempt to prevent accidental uses of Make_Return_Statement. If this -- Attempt to prevent accidental uses of Make_Return_Statement. If this
-- and the one in Nmake are both potentially use-visible, it will cause -- and the one in Nmake are both potentially use-visible, it will cause
......
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