-- declaration and at the point of use match.
if Is_OK_Ghost_Context (Ghost_Ref) then
- Check_Ghost_Policy (Ghost_Id, Ghost_Ref);
+ if Present (Ghost_Id) then
+ Check_Ghost_Policy (Ghost_Id, Ghost_Ref);
+ end if;
-- Otherwise the Ghost entity appears in a non-Ghost context and affects
-- its behavior or value (SPARK RM 6.9(10,11)).
Ghost_Ref);
Error_Msg_N
("\either make the type ghost "
+ & "or use a Ghost_Predicate "
& "or use a type invariant on a private type", Ghost_Ref);
end if;
end if;
return False;
end Is_Ghost_Assignment;
+ ----------------------------------
+ -- Is_Ghost_Attribute_Reference --
+ ----------------------------------
+
+ function Is_Ghost_Attribute_Reference (N : Node_Id) return Boolean is
+ begin
+ return Nkind (N) = N_Attribute_Reference
+ and then Attribute_Name (N) = Name_Initialized;
+ end Is_Ghost_Attribute_Reference;
+
--------------------------
-- Is_Ghost_Declaration --
--------------------------
-- Determine whether arbitrary node N denotes an assignment statement whose
-- target is a Ghost entity.
+ function Is_Ghost_Attribute_Reference (N : Node_Id) return Boolean;
+ -- Determine whether arbitrary node N denotes an attribute reference which
+ -- denotes a Ghost attribute.
+
function Is_Ghost_Declaration (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a declaration which defines
-- a Ghost entity.
with Exp_Util; use Exp_Util;
with Expander; use Expander;
with Freeze; use Freeze;
+with Ghost; use Ghost;
with Gnatvsn; use Gnatvsn;
with Itypes; use Itypes;
with Lib; use Lib;
Set_Etype (N, Typ);
end if;
+ -- A Ghost attribute must appear in a specific context
+
+ if Is_Ghost_Attribute_Reference (N) then
+ Check_Ghost_Context (Empty, N);
+ end if;
+
-- Remaining processing depends on attribute
case Attr_Id is