-- case. We could perhaps do a more accurate job and retain some of the
-- warnings, but it is quite a tricky job.
+ Ghost_Context_Checks_Disabled : Boolean := False;
+ -- This flag controls whether ghost context related checks are enabled or
+ -- disabled. Typically they are enabled however they need to be disabled in
+ -- instances where the ghost region context has not been set.
+ --
+ -- Typically this is done for pragmas where the ghostliness of the pragma
+ -- is determined by an entity specified as one of the arguments. In these
+ -- cases we need to analyze that argument before the pragma itself to
+ -- determine the ghostliness of the pragma. However at that point we have
+ -- not set the ghost region for the pragma in order to determine the ghost
+ -- context of the argument.
+
-----------------------------------
-- Handling of Check Suppression --
-----------------------------------
end if;
end if;
+ -- We are going to check the entity that determines the ghost
+ -- region of that pragma. We need to disable the checks for ghost
+ -- context since the ghost region can only be set after analyzing
+ -- this entity.
+
+ Ghost_Context_Checks_Disabled := True;
Analyze (Argx);
+ Ghost_Context_Checks_Disabled := False;
if Nkind (Argx) not in N_Direct_Name
and then (Nkind (Argx) /= N_Attribute_Reference
Check_Optional_Identifier (Arg2, Name_Entity);
Check_Arg_Is_Local_Name (Arg2);
+ -- We are going to check the entity that determines the ghost
+ -- region of that pragma. We need to disable the checks for ghost
+ -- context since the ghost region can only be set after analyzing
+ -- this entity.
+
+ Ghost_Context_Checks_Disabled := True;
Id := Get_Pragma_Arg (Arg2);
Analyze (Id);
+ Ghost_Context_Checks_Disabled := False;
if not Is_Entity_Name (Id) then
Error_Pragma_Arg ("entity name required", Arg2);
Check_Optional_Identifier (Arg2, Name_On);
E_Id := Get_Pragma_Arg (Arg2);
+
+ -- We are going to check the entity that determines the ghost
+ -- region of that pragma. We need to disable the checks for ghost
+ -- context since the ghost region can only be set after analyzing
+ -- this entity.
+
+ Ghost_Context_Checks_Disabled := True;
Analyze (E_Id);
+ Ghost_Context_Checks_Disabled := False;
if not Is_Entity_Name (E_Id) then
Error_Pragma_Arg
Check_Ada_83_Warning;
Check_No_Identifiers;
Check_Arg_Count (1);
+
Check_Arg_Is_Local_Name (Arg1);
if Debug_Flag_U then
end if;
C_Ent := Cunit_Entity (Current_Sem_Unit);
+
+ -- We are going to check the entity that determines the ghost
+ -- region of that pragma. We need to disable the checks for ghost
+ -- context since the ghost region can only be set after analyzing
+ -- this entity.
+
+ Ghost_Context_Checks_Disabled := True;
Analyze (Get_Pragma_Arg (Arg1));
Nm := Entity (Get_Pragma_Arg (Arg1));
+ Ghost_Context_Checks_Disabled := False;
-- A pragma that applies to a Ghost entity becomes Ghost for the
-- purposes of legality checks and removal of ignored Ghost code.
while Present (Arg) loop
Check_Arg_Is_Local_Name (Arg);
Id := Get_Pragma_Arg (Arg);
+
+ -- We are going to check the entity that determines the ghost
+ -- region of that pragma. We need to disable the checks for
+ -- ghost context since the ghost region can only be set after
+ -- analyzing this entity.
+
+ Ghost_Context_Checks_Disabled := True;
Analyze (Id);
+ Ghost_Context_Checks_Disabled := False;
if not Is_Entity_Name (Id) then
Error_Pragma_Arg ("entity name required", Arg);