Commit e090bc75 by Robert Dewar Committed by Arnaud Charlet

sem_elab.adb (Check_A_Call): Specialize elaboration warnings on elaboration model

2007-04-20  Robert Dewar  <dewar@adacore.com>

	* sem_elab.adb (Check_A_Call): Specialize elaboration warnings on
	elaboration model
	(Check_A_Call): Add check for entry call which was causing blowup

From-SVN: r125454
parent f377c995
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1997-2007, 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- --
...@@ -849,38 +849,77 @@ package body Sem_Elab is ...@@ -849,38 +849,77 @@ package body Sem_Elab is
and then Elab_Warnings and then Elab_Warnings
and then Generate_Warnings and then Generate_Warnings
then then
if Inst_Case then Generate_Elab_Warnings : declare
Error_Msg_NE procedure Elab_Warning
("instantiation of& may raise Program_Error?", N, Ent); (Msg_D : String;
Msg_S : String;
Ent : Node_Or_Entity_Id);
-- Generate a call to Error_Msg_NE with parameters Msg_D or
-- Msg_S (for dynamic or static elaboration model), N and Ent.
------------------
-- Elab_Warning --
------------------
procedure Elab_Warning
(Msg_D : String;
Msg_S : String;
Ent : Node_Or_Entity_Id)
is
begin
if Dynamic_Elaboration_Checks then
Error_Msg_NE (Msg_D, N, Ent);
else
Error_Msg_NE (Msg_S, N, Ent);
end if;
end Elab_Warning;
else -- Start of processing for Generate_Elab_Warnings
if Is_Init_Proc (Entity (Name (N)))
and then Comes_From_Source (Ent) begin
then if Inst_Case then
Error_Msg_NE Elab_Warning
("implicit call to & may raise Program_Error?", N, Ent); ("instantiation of& may raise Program_Error?",
"instantiation of& during elaboration?", Ent);
else else
Error_Msg_NE if Nkind (Name (N)) in N_Has_Entity
("call to & may raise Program_Error?", N, Ent); and then Is_Init_Proc (Entity (Name (N)))
and then Comes_From_Source (Ent)
then
Elab_Warning
("implicit call to & may raise Program_Error?",
"implicit call to & during elaboration?",
Ent);
else
Elab_Warning
("call to & may raise Program_Error?",
"call to & during elaboration?",
Ent);
end if;
end if; end if;
end if;
Error_Msg_Qual_Level := Nat'Last; Error_Msg_Qual_Level := Nat'Last;
if Nkind (N) in N_Subprogram_Instantiation then if Nkind (N) in N_Subprogram_Instantiation then
Error_Msg_NE Elab_Warning
("\missing pragma Elaborate for&?", N, W_Scope); ("\missing pragma Elaborate for&?",
else "\implicit pragma Elaborate for& generated?",
Error_Msg_NE W_Scope);
("\missing pragma Elaborate_All for&?", N, W_Scope); else
end if; Elab_Warning
("\missing pragma Elaborate_All for&?",
"\implicit pragma Elaborate_All for & generated?",
W_Scope);
end if;
end Generate_Elab_Warnings;
Error_Msg_Qual_Level := 0; Error_Msg_Qual_Level := 0;
Output_Calls (N); Output_Calls (N);
-- Set flag to prevent further warnings for same unit -- Set flag to prevent further warnings for same unit unless in
-- unless in All_Errors_Mode. -- All_Errors_Mode.
if not All_Errors_Mode and not Dynamic_Elaboration_Checks then if not All_Errors_Mode and not Dynamic_Elaboration_Checks then
Set_Suppress_Elaboration_Warnings (W_Scope, True); Set_Suppress_Elaboration_Warnings (W_Scope, True);
...@@ -1695,7 +1734,7 @@ package body Sem_Elab is ...@@ -1695,7 +1734,7 @@ package body Sem_Elab is
Expander_Mode_Save_And_Set (True); Expander_Mode_Save_And_Set (True);
for J in Delay_Check.First .. Delay_Check.Last loop for J in Delay_Check.First .. Delay_Check.Last loop
New_Scope (Delay_Check.Table (J).Curscop); Push_Scope (Delay_Check.Table (J).Curscop);
From_Elab_Code := Delay_Check.Table (J).From_Elab_Code; From_Elab_Code := Delay_Check.Table (J).From_Elab_Code;
Check_Internal_Call_Continue ( Check_Internal_Call_Continue (
...@@ -2114,7 +2153,7 @@ package body Sem_Elab is ...@@ -2114,7 +2153,7 @@ package body Sem_Elab is
begin begin
Set_Elaboration_Entity (E, Ent); Set_Elaboration_Entity (E, Ent);
New_Scope (Scope (E)); Push_Scope (Scope (E));
Insert_Action (Declaration_Node (E), Insert_Action (Declaration_Node (E),
Make_Object_Declaration (Loce, Make_Object_Declaration (Loce,
...@@ -3017,7 +3056,7 @@ package body Sem_Elab is ...@@ -3017,7 +3056,7 @@ package body Sem_Elab is
declare declare
Spec : constant Node_Id := Specification (N); Spec : constant Node_Id := Specification (N);
begin begin
New_Scope (Defining_Unit_Name (Spec)); Push_Scope (Defining_Unit_Name (Spec));
Supply_Bodies (Visible_Declarations (Spec)); Supply_Bodies (Visible_Declarations (Spec));
Supply_Bodies (Private_Declarations (Spec)); Supply_Bodies (Private_Declarations (Spec));
Pop_Scope; Pop_Scope;
......
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