Commit ac7d724d by Ed Schonberg Committed by Arnaud Charlet

sem_ch5.adb: remove spurious warning from non-empty loop.

2013-04-11  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch5.adb: remove spurious warning from non-empty loop.
	* sem_ch8.adb (Enclosing_Instance): Make public to other routines
	in the package, in order to suppress redundant semantic checks
	on subprogram renamings in nested instantiations.

From-SVN: r197746
parent 8fde064e
2013-04-11 Ed Schonberg <schonberg@adacore.com>
* sem_ch5.adb: remove spurious warning from non-empty loop.
* sem_ch8.adb (Enclosing_Instance): Make public to other routines
in the package, in order to suppress redundant semantic checks
on subprogram renamings in nested instantiations.
2013-04-11 Robert Dewar <dewar@adacore.com> 2013-04-11 Robert Dewar <dewar@adacore.com>
* errout.ads: Minor reformatting. * errout.ads: Minor reformatting.
......
...@@ -222,10 +222,9 @@ package body Sem_Ch5 is ...@@ -222,10 +222,9 @@ package body Sem_Ch5 is
if Is_Entity_Name (Opnd) if Is_Entity_Name (Opnd)
and then (Ekind (Entity (Opnd)) = E_Out_Parameter and then (Ekind (Entity (Opnd)) = E_Out_Parameter
or else Ekind (Entity (Opnd)) = or else Ekind_In (Entity (Opnd),
E_In_Out_Parameter E_In_Out_Parameter,
or else Ekind (Entity (Opnd)) = E_Generic_In_Out_Parameter)
E_Generic_In_Out_Parameter
or else or else
(Ekind (Entity (Opnd)) = E_Variable (Ekind (Entity (Opnd)) = E_Variable
and then Nkind (Parent (Entity (Opnd))) = and then Nkind (Parent (Entity (Opnd))) =
...@@ -607,9 +606,7 @@ package body Sem_Ch5 is ...@@ -607,9 +606,7 @@ package body Sem_Ch5 is
-- as well to anonymous access-to-subprogram types that are component -- as well to anonymous access-to-subprogram types that are component
-- subtypes or formal parameters. -- subtypes or formal parameters.
if Ada_Version >= Ada_2005 if Ada_Version >= Ada_2005 and then Is_Access_Type (T1) then
and then Is_Access_Type (T1)
then
if Is_Local_Anonymous_Access (T1) if Is_Local_Anonymous_Access (T1)
or else Ekind (T2) = E_Anonymous_Access_Subprogram_Type or else Ekind (T2) = E_Anonymous_Access_Subprogram_Type
...@@ -665,11 +662,9 @@ package body Sem_Ch5 is ...@@ -665,11 +662,9 @@ package body Sem_Ch5 is
-- assignment within the block. -- assignment within the block.
elsif Is_Array_Type (T1) elsif Is_Array_Type (T1)
and then and then (Nkind (Rhs) /= N_Type_Conversion
(Nkind (Rhs) /= N_Type_Conversion
or else Is_Constrained (Etype (Rhs))) or else Is_Constrained (Etype (Rhs)))
and then and then (Nkind (Rhs) /= N_Function_Call
(Nkind (Rhs) /= N_Function_Call
or else Nkind (N) /= N_Block_Statement) or else Nkind (N) /= N_Block_Statement)
then then
-- Assignment verifies that the length of the Lsh and Rhs are equal, -- Assignment verifies that the length of the Lsh and Rhs are equal,
...@@ -1198,9 +1193,7 @@ package body Sem_Ch5 is ...@@ -1198,9 +1193,7 @@ package body Sem_Ch5 is
-- A case statement with a single OTHERS alternative is not allowed -- A case statement with a single OTHERS alternative is not allowed
-- in SPARK. -- in SPARK.
if Others_Present if Others_Present and then List_Length (Alternatives (N)) = 1 then
and then List_Length (Alternatives (N)) = 1
then
Check_SPARK_Restriction Check_SPARK_Restriction
("OTHERS as unique case alternative is not allowed", N); ("OTHERS as unique case alternative is not allowed", N);
end if; end if;
...@@ -1297,9 +1290,7 @@ package body Sem_Ch5 is ...@@ -1297,9 +1290,7 @@ package body Sem_Ch5 is
Scope_Id := Scope_Stack.Table (J).Entity; Scope_Id := Scope_Stack.Table (J).Entity;
Kind := Ekind (Scope_Id); Kind := Ekind (Scope_Id);
if Kind = E_Loop if Kind = E_Loop and then (No (Target) or else Scope_Id = U_Name) then
and then (No (Target) or else Scope_Id = U_Name)
then
Set_Has_Exit (Scope_Id); Set_Has_Exit (Scope_Id);
exit; exit;
...@@ -1423,9 +1414,7 @@ package body Sem_Ch5 is ...@@ -1423,9 +1414,7 @@ package body Sem_Ch5 is
Scope_Id := Scope_Stack.Table (J).Entity; Scope_Id := Scope_Stack.Table (J).Entity;
if Label_Scope = Scope_Id if Label_Scope = Scope_Id
or else (Ekind (Scope_Id) /= E_Block or else not Ekind_In (Scope_Id, E_Block, E_Loop, E_Return_Statement)
and then Ekind (Scope_Id) /= E_Loop
and then Ekind (Scope_Id) /= E_Return_Statement)
then then
if Scope_Id /= Label_Scope then if Scope_Id /= Label_Scope then
Error_Msg_N Error_Msg_N
...@@ -1447,9 +1436,9 @@ package body Sem_Ch5 is ...@@ -1447,9 +1436,9 @@ package body Sem_Ch5 is
-- The expander has circuitry to completely delete code that it can tell -- The expander has circuitry to completely delete code that it can tell
-- will not be executed (as a result of compile time known conditions). In -- will not be executed (as a result of compile time known conditions). In
-- the analyzer, we ensure that code that will be deleted in this manner is -- the analyzer, we ensure that code that will be deleted in this manner
-- analyzed but not expanded. This is obviously more efficient, but more -- is analyzed but not expanded. This is obviously more efficient, but
-- significantly, difficulties arise if code is expanded and then -- more significantly, difficulties arise if code is expanded and then
-- eliminated (e.g. exception table entries disappear). Similarly, itypes -- eliminated (e.g. exception table entries disappear). Similarly, itypes
-- generated in deleted code must be frozen from start, because the nodes -- generated in deleted code must be frozen from start, because the nodes
-- on which they depend will not be available at the freeze point. -- on which they depend will not be available at the freeze point.
...@@ -2161,15 +2150,11 @@ package body Sem_Ch5 is ...@@ -2161,15 +2150,11 @@ package body Sem_Ch5 is
-- Propagate staticness to loop range itself, in case the -- Propagate staticness to loop range itself, in case the
-- corresponding subtype is static. -- corresponding subtype is static.
if New_Lo /= Lo if New_Lo /= Lo and then Is_Static_Expression (New_Lo) then
and then Is_Static_Expression (New_Lo)
then
Rewrite (Low_Bound (R), New_Copy (New_Lo)); Rewrite (Low_Bound (R), New_Copy (New_Lo));
end if; end if;
if New_Hi /= Hi if New_Hi /= Hi and then Is_Static_Expression (New_Hi) then
and then Is_Static_Expression (New_Hi)
then
Rewrite (High_Bound (R), New_Copy (New_Hi)); Rewrite (High_Bound (R), New_Copy (New_Hi));
end if; end if;
end Process_Bounds; end Process_Bounds;
...@@ -2238,8 +2223,7 @@ package body Sem_Ch5 is ...@@ -2238,8 +2223,7 @@ package body Sem_Ch5 is
-- new iterator form. -- new iterator form.
if Nkind (DS_Copy) = N_Function_Call if Nkind (DS_Copy) = N_Function_Call
or else or else (Is_Entity_Name (DS_Copy)
(Is_Entity_Name (DS_Copy)
and then not Is_Type (Entity (DS_Copy))) and then not Is_Type (Entity (DS_Copy)))
then then
-- This is an iterator specification. Rewrite it as such and -- This is an iterator specification. Rewrite it as such and
...@@ -2395,9 +2379,8 @@ package body Sem_Ch5 is ...@@ -2395,9 +2379,8 @@ package body Sem_Ch5 is
-- instance, since in practice they tend to be dubious in these -- instance, since in practice they tend to be dubious in these
-- cases since they can result from intended parametrization. -- cases since they can result from intended parametrization.
if not Inside_A_Generic if not Inside_A_Generic and then not In_Instance then
and then not In_Instance
then
-- Specialize msg if invalid values could make the loop -- Specialize msg if invalid values could make the loop
-- non-null after all. -- non-null after all.
...@@ -2436,7 +2419,7 @@ package body Sem_Ch5 is ...@@ -2436,7 +2419,7 @@ package body Sem_Ch5 is
-- The other case for a warning is a reverse loop where the -- The other case for a warning is a reverse loop where the
-- upper bound is the integer literal zero or one, and the -- upper bound is the integer literal zero or one, and the
-- lower bound can be positive. -- lower bound may exceed this value.
-- For example, we have -- For example, we have
...@@ -2449,11 +2432,24 @@ package body Sem_Ch5 is ...@@ -2449,11 +2432,24 @@ package body Sem_Ch5 is
and then Nkind (Original_Node (H)) = N_Integer_Literal and then Nkind (Original_Node (H)) = N_Integer_Literal
and then and then
(Intval (Original_Node (H)) = Uint_0 (Intval (Original_Node (H)) = Uint_0
or else Intval (Original_Node (H)) = Uint_1) or else
Intval (Original_Node (H)) = Uint_1)
then then
-- Lower bound may in fact be known and known not to exceed
-- upper bound (e.g. reverse 0 .. 1) and that's OK.
if Compile_Time_Known_Value (L)
and then Expr_Value (L) <= Expr_Value (H)
then
null;
-- Otherwise warning is warranted
else
Error_Msg_N ("??loop range may be null", DS); Error_Msg_N ("??loop range may be null", DS);
Error_Msg_N ("\??bounds may be wrong way round", DS); Error_Msg_N ("\??bounds may be wrong way round", DS);
end if; end if;
end if;
end; end;
end if; end if;
end Analyze_Loop_Parameter_Specification; end Analyze_Loop_Parameter_Specification;
...@@ -2839,9 +2835,7 @@ package body Sem_Ch5 is ...@@ -2839,9 +2835,7 @@ package body Sem_Ch5 is
P : Node_Id; P : Node_Id;
begin begin
if Is_List_Member (N) if Is_List_Member (N) and then Comes_From_Source (N) then
and then Comes_From_Source (N)
then
declare declare
Nxt : Node_Id; Nxt : Node_Id;
...@@ -2993,9 +2987,8 @@ package body Sem_Ch5 is ...@@ -2993,9 +2987,8 @@ package body Sem_Ch5 is
Analyze (R_Copy); Analyze (R_Copy);
if Nkind (R_Copy) in N_Subexpr if Nkind (R_Copy) in N_Subexpr and then Is_Overloaded (R_Copy) then
and then Is_Overloaded (R_Copy)
then
-- Apply preference rules for range of predefined integer types, or -- Apply preference rules for range of predefined integer types, or
-- diagnose true ambiguity. -- diagnose true ambiguity.
...@@ -3037,9 +3030,7 @@ package body Sem_Ch5 is ...@@ -3037,9 +3030,7 @@ package body Sem_Ch5 is
-- Subtype mark in iteration scheme -- Subtype mark in iteration scheme
if Is_Entity_Name (R_Copy) if Is_Entity_Name (R_Copy) and then Is_Type (Entity (R_Copy)) then
and then Is_Type (Entity (R_Copy))
then
null; null;
-- Expression in range, or Ada 2012 iterator -- Expression in range, or Ada 2012 iterator
......
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