CW_Typ : Entity_Id;
Decl : Node_Id;
Ins_Nod : Node_Id;
- Subp : Node_Id;
Temp : Entity_Id;
use Old_Attr_Util.Conditional_Evaluation;
return;
end if;
- -- Climb the parent chain looking for subprogram _Wrapped_Statements
-
- Subp := N;
- while Present (Subp) loop
- exit when Nkind (Subp) = N_Subprogram_Body
- and then Chars (Defining_Entity (Subp))
- = Name_uWrapped_Statements;
-
- -- If assertions are disabled, no need to create the declaration
- -- that preserves the value. The postcondition pragma in which
- -- 'Old appears will be checked or disabled according to the
- -- current policy in effect.
-
- if Nkind (Subp) = N_Pragma and then not Is_Checked (Subp) then
- return;
- end if;
-
- Subp := Parent (Subp);
- end loop;
- Subp := Empty;
-
-- 'Old can only appear in the case where local contract-related
-- wrapper has been generated with the purpose of wrapping the
-- original declarations and statements.
Mutate_Ekind (Temp, E_Constant);
Set_Stores_Attribute_Old_Prefix (Temp);
- -- Push the scope of the related subprogram where _Postcondition
- -- resides as this ensures that the object will be analyzed in the
- -- proper context.
-
- if Present (Subp) then
- Push_Scope (Scope (Defining_Entity (Subp)));
-
- -- No need to push the scope when generating C code since the
- -- _Postcondition procedure has been inlined.
-
- else
- null;
- end if;
-
-- Locate the insertion place of the internal temporary that saves
-- the 'Old value.
- if Present (Subp) then
- Ins_Nod := Subp;
+ Ins_Nod := N;
+ while Nkind (Ins_Nod) /= N_Subprogram_Body loop
+ Ins_Nod := Parent (Ins_Nod);
+ end loop;
- -- General case where the postcondition checks occur after the call
- -- to _Wrapped_Statements.
+ pragma Assert (Present (Wrapped_Statements
+ (if Acts_As_Spec (Ins_Nod)
+ then Defining_Unit_Name (Specification (Ins_Nod))
+ else Corresponding_Spec (Ins_Nod))));
- else
- Ins_Nod := N;
- while Nkind (Ins_Nod) /= N_Subprogram_Body loop
- Ins_Nod := Parent (Ins_Nod);
- end loop;
-
- if Present (Corresponding_Spec (Ins_Nod))
- and then Present
- (Wrapped_Statements (Corresponding_Spec (Ins_Nod)))
- then
- Ins_Nod := Last (Declarations (Ins_Nod));
- else
- Ins_Nod := First (Declarations (Ins_Nod));
- end if;
- end if;
+ Ins_Nod := Last (Declarations (Ins_Nod));
if Eligible_For_Conditional_Evaluation (N) then
declare
(Temp => Temp,
Typ => Etype (Pref),
Loc => Loc));
-
- if Present (Subp) then
- Pop_Scope;
- end if;
return;
end;
end if;
- if Present (Subp) then
- Pop_Scope;
- end if;
-
-- Ensure that the prefix of attribute 'Old is valid. The check must
-- be inserted after the expansion of the attribute has taken place
-- to reflect the new placement of the prefix.
| Pragma_Post
| Pragma_Postcondition
| Pragma_Post_Class
- | Pragma_Refined_Post);
+ | Pragma_Refined_Post
+ | Pragma_Test_Case);
return (1 .. 0 => <>); -- recursion terminates here
end if;
Determiners : constant Determining_Expression_List :=
Determining_Expressions (Expr);
begin
- pragma Assert (Determiners'Length > 0);
+ pragma Assert (if Serious_Errors_Detected = 0 then
+ Determiners'Length > 0);
for Idx in Determiners'Range loop
if not Is_Known_On_Entry (Determiners (Idx).Expr) then