Commit 8a0320ad by Arnaud Charlet

[multiple changes]

2012-06-26  Vincent Pucci  <pucci@adacore.com>

	* exp_ch3.adb (Build_Init_Statements): Don't check the parents
	in the Rep Item Chain of the task for aspects Interrupt_Priority,
	Priority, CPU and Dispatching_Domain.
	* exp_ch9.adb (Expand_N_Task_Type_Declaration): fields _Priority,
	_CPU and _Domain are present in the corresponding record type
	only if the task entity has a pragma, attribute definition
	clause or aspect specification.
	(Make_Initialize_Protection): Don't check the parents in the Rep Item
	Chain of the task for aspects Interrupt_Priority, Priority, CPU and
	Dispatching_Domain.
	* freeze.adb (Freeze_Entity): Use of Evaluate_Aspects_At_Freeze_Point
	call replaced by Analyze_Aspects_At_Freeze_Point.
	* sem_ch13.adb, sem_ch13.ads (Analyze_Aspects_At_Freeze_Point):
	Renaming of Evaluate_Aspects_At_Freeze_Point.

2012-06-26  Yannick Moy  <moy@adacore.com>

	* sem_attr.adb (Analyze_Attribute): Detect if 'Old is used outside a
	postcondition, and issue an error in such a case.

2012-06-26  Yannick Moy  <moy@adacore.com>

	* gnat_rm.texi: Minor editing.

2012-06-26  Tristan Gingold  <gingold@adacore.com>

	* raise-gcc.c: Minor cleanup: remove unused prototype.
	* seh_init.c: Do not create an image wide unwind info to catch
	SEH when SEH unwind info are emitted by the compiler.

From-SVN: r188995
parent 59b7e90f
2012-06-26 Vincent Pucci <pucci@adacore.com>
* exp_ch3.adb (Build_Init_Statements): Don't check the parents
in the Rep Item Chain of the task for aspects Interrupt_Priority,
Priority, CPU and Dispatching_Domain.
* exp_ch9.adb (Expand_N_Task_Type_Declaration): fields _Priority,
_CPU and _Domain are present in the corresponding record type
only if the task entity has a pragma, attribute definition
clause or aspect specification.
(Make_Initialize_Protection): Don't check the parents in the Rep Item
Chain of the task for aspects Interrupt_Priority, Priority, CPU and
Dispatching_Domain.
* freeze.adb (Freeze_Entity): Use of Evaluate_Aspects_At_Freeze_Point
call replaced by Analyze_Aspects_At_Freeze_Point.
* sem_ch13.adb, sem_ch13.ads (Analyze_Aspects_At_Freeze_Point):
Renaming of Evaluate_Aspects_At_Freeze_Point.
2012-06-26 Yannick Moy <moy@adacore.com>
* sem_attr.adb (Analyze_Attribute): Detect if 'Old is used outside a
postcondition, and issue an error in such a case.
2012-06-26 Yannick Moy <moy@adacore.com>
* gnat_rm.texi: Minor editing.
2012-06-26 Tristan Gingold <gingold@adacore.com>
* raise-gcc.c: Minor cleanup: remove unused prototype.
* seh_init.c: Do not create an image wide unwind info to catch
SEH when SEH unwind info are emitted by the compiler.
2012-06-19 Steven Bosscher <steven@gcc.gnu.org> 2012-06-19 Steven Bosscher <steven@gcc.gnu.org>
* gcc-interface/trans.c: Include target.h. * gcc-interface/trans.c: Include target.h.
......
...@@ -2668,7 +2668,9 @@ package body Exp_Ch3 is ...@@ -2668,7 +2668,9 @@ package body Exp_Ch3 is
Ritem := Ritem :=
Get_Rep_Item Get_Rep_Item
(Corresponding_Concurrent_Type (Scope (Id)), Nam); (Corresponding_Concurrent_Type (Scope (Id)),
Nam,
Check_Parents => False);
if Present (Ritem) then if Present (Ritem) then
......
...@@ -11270,30 +11270,36 @@ package body Exp_Ch9 is ...@@ -11270,30 +11270,36 @@ package body Exp_Ch9 is
-- in the pragma, and is used to override the task stack size otherwise -- in the pragma, and is used to override the task stack size otherwise
-- associated with the task type. -- associated with the task type.
-- The _Priority field is always present. It will be filled at the freeze -- The _Priority field is present only if the task entity has a Priority or
-- point, when the record init proc is built, to capture the expression of -- Interrupt_Priority rep item (pragma, aspect specification or attribute
-- a Priority pragma, attribute definition clause or aspect specification -- definition clause). It will be filled at the freeze point, when the
-- (see Build_Record_Init_Proc in Exp_Ch3). -- record init proc is built, to capture the expression of the rep item
-- (see Build_Record_Init_Proc in Exp_Ch3). Note that it cannot be filled
-- here since aspect evaluations are delayed till the freeze point.
-- The _Task_Info field is present only if a Task_Info pragma appears in -- The _Task_Info field is present only if a Task_Info pragma appears in
-- the task definition. The expression captures the argument that was -- the task definition. The expression captures the argument that was
-- present in the pragma, and is used to provide the Task_Image parameter -- present in the pragma, and is used to provide the Task_Image parameter
-- to the call to Create_Task. -- to the call to Create_Task.
-- The _CPU field is always present. It will be filled at the freeze point, -- The _CPU field is present only if the task entity has a CPU rep item
-- when the record init proc is built, to capture the expression of a CPU -- (pragma, aspect specification or attribute definition clause). It will
-- pragma, attribute definition clause or aspect specification (see -- be filled at the freeze point, when the record init proc is built, to
-- Build_Record_Init_Proc in Exp_Ch3). -- capture the expression of the rep item (see Build_Record_Init_Proc in
-- Exp_Ch3). Note that it cannot be filled here since aspect evaluations
-- are delayed till the freeze point.
-- The _Relative_Deadline field is present only if a Relative_Deadline -- The _Relative_Deadline field is present only if a Relative_Deadline
-- pragma appears in the task definition. The expression captures the -- pragma appears in the task definition. The expression captures the
-- argument that was present in the pragma, and is used to provide the -- argument that was present in the pragma, and is used to provide the
-- Relative_Deadline parameter to the call to Create_Task. -- Relative_Deadline parameter to the call to Create_Task.
-- The _Domain field is always present. It will be filled at the freeze -- The _Domain field is present only if the task entity has a
-- point, when the record init proc is built, to capture the expression of -- Dispatching_Domain rep item (pragma, aspect specification or attribute
-- a Dispatching_Domain pragma, attribute definition clause or aspect -- definition clause). It will be filled at the freeze point, when the
-- specification (see Build_Record_Init_Proc in Exp_Ch3). -- record init proc is built, to capture the expression of the rep item
-- (see Build_Record_Init_Proc in Exp_Ch3). Note that it cannot be filled
-- here since aspect evaluations are delayed till the freeze point.
-- When a task is declared, an instance of the task value record is -- When a task is declared, an instance of the task value record is
-- created. The elaboration of this declaration creates the correct bounds -- created. The elaboration of this declaration creates the correct bounds
...@@ -11566,17 +11572,20 @@ package body Exp_Ch9 is ...@@ -11566,17 +11572,20 @@ package body Exp_Ch9 is
Collect_Entry_Families (Loc, Cdecls, Size_Decl, Tasktyp); Collect_Entry_Families (Loc, Cdecls, Size_Decl, Tasktyp);
-- Add the _Priority component with no expression -- Add the _Priority component if a Interrupt_Priority or Priority rep
-- item is present.
Append_To (Cdecls, if Has_Rep_Item (TaskId, Name_Priority, Check_Parents => False) then
Make_Component_Declaration (Loc, Append_To (Cdecls,
Defining_Identifier => Make_Component_Declaration (Loc,
Make_Defining_Identifier (Loc, Name_uPriority), Defining_Identifier =>
Component_Definition => Make_Defining_Identifier (Loc, Name_uPriority),
Make_Component_Definition (Loc, Component_Definition =>
Aliased_Present => False, Make_Component_Definition (Loc,
Subtype_Indication => Aliased_Present => False,
New_Reference_To (Standard_Integer, Loc)))); Subtype_Indication =>
New_Reference_To (Standard_Integer, Loc))));
end if;
-- Add the _Size component if a Storage_Size pragma is present -- Add the _Size component if a Storage_Size pragma is present
...@@ -11623,18 +11632,20 @@ package body Exp_Ch9 is ...@@ -11623,18 +11632,20 @@ package body Exp_Ch9 is
(TaskId, Name_Task_Info, Check_Parents => False))))))); (TaskId, Name_Task_Info, Check_Parents => False)))))));
end if; end if;
-- Add the _CPU component with no expression -- Add the _CPU component if a CPU rep item is present
Append_To (Cdecls, if Has_Rep_Item (TaskId, Name_CPU, Check_Parents => False) then
Make_Component_Declaration (Loc, Append_To (Cdecls,
Defining_Identifier => Make_Component_Declaration (Loc,
Make_Defining_Identifier (Loc, Name_uCPU), Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uCPU),
Component_Definition => Component_Definition =>
Make_Component_Definition (Loc, Make_Component_Definition (Loc,
Aliased_Present => False, Aliased_Present => False,
Subtype_Indication => Subtype_Indication =>
New_Reference_To (RTE (RE_CPU_Range), Loc)))); New_Reference_To (RTE (RE_CPU_Range), Loc))));
end if;
-- Add the _Relative_Deadline component if a Relative_Deadline pragma is -- Add the _Relative_Deadline component if a Relative_Deadline pragma is
-- present. If we are using a restricted run time this component will -- present. If we are using a restricted run time this component will
...@@ -11663,11 +11674,16 @@ package body Exp_Ch9 is ...@@ -11663,11 +11674,16 @@ package body Exp_Ch9 is
Get_Relative_Deadline_Pragma (Taskdef)))))))); Get_Relative_Deadline_Pragma (Taskdef))))))));
end if; end if;
-- Add the _Dispatching_Domain component with no expression. If we are -- Add the _Dispatching_Domain component if a Dispatching_Domain rep
-- using a restricted run time this component will not be added -- item is present. If we are using a restricted run time this component
-- (dispatching domains are not allowed by the Ravenscar profile). -- will not be added (dispatching domains are not allowed by the
-- Ravenscar profile).
if not Restricted_Profile then if not Restricted_Profile
and then
Has_Rep_Item
(TaskId, Name_Dispatching_Domain, Check_Parents => False)
then
Append_To (Cdecls, Append_To (Cdecls,
Make_Component_Declaration (Loc, Make_Component_Declaration (Loc,
Defining_Identifier => Defining_Identifier =>
...@@ -13344,10 +13360,11 @@ package body Exp_Ch9 is ...@@ -13344,10 +13360,11 @@ package body Exp_Ch9 is
-- Interrupt_Priority'Last, an implementation-defined value, see -- Interrupt_Priority'Last, an implementation-defined value, see
-- (RM D.3(10)). -- (RM D.3(10)).
if Has_Rep_Item (Ptyp, Name_Priority) then if Has_Rep_Item (Ptyp, Name_Priority, Check_Parents => False) then
declare declare
Prio_Clause : constant Node_Id := Prio_Clause : constant Node_Id :=
Get_Rep_Item (Ptyp, Name_Priority); Get_Rep_Item
(Ptyp, Name_Priority, Check_Parents => False);
Prio : Node_Id; Prio : Node_Id;
Temp : Entity_Id; Temp : Entity_Id;
...@@ -13670,7 +13687,7 @@ package body Exp_Ch9 is ...@@ -13670,7 +13687,7 @@ package body Exp_Ch9 is
-- Priority parameter. Set to Unspecified_Priority unless there is a -- Priority parameter. Set to Unspecified_Priority unless there is a
-- Priority rep item, in which case we take the value from the rep item. -- Priority rep item, in which case we take the value from the rep item.
if Has_Rep_Item (Ttyp, Name_Priority) then if Has_Rep_Item (Ttyp, Name_Priority, Check_Parents => False) then
Append_To (Args, Append_To (Args,
Make_Selected_Component (Loc, Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_uInit), Prefix => Make_Identifier (Loc, Name_uInit),
...@@ -13741,7 +13758,7 @@ package body Exp_Ch9 is ...@@ -13741,7 +13758,7 @@ package body Exp_Ch9 is
-- passed as an Integer because in the case of unspecified CPU the -- passed as an Integer because in the case of unspecified CPU the
-- value is not in the range of CPU_Range. -- value is not in the range of CPU_Range.
if Has_Rep_Item (Ttyp, Name_CPU) then if Has_Rep_Item (Ttyp, Name_CPU, Check_Parents => False) then
Append_To (Args, Append_To (Args,
Convert_To (Standard_Integer, Convert_To (Standard_Integer,
Make_Selected_Component (Loc, Make_Selected_Component (Loc,
...@@ -13790,7 +13807,9 @@ package body Exp_Ch9 is ...@@ -13790,7 +13807,9 @@ package body Exp_Ch9 is
-- Case where Dispatching_Domain rep item applies: use given value -- Case where Dispatching_Domain rep item applies: use given value
if Has_Rep_Item (Ttyp, Name_Dispatching_Domain) then if Has_Rep_Item
(Ttyp, Name_Dispatching_Domain, Check_Parents => False)
then
Append_To (Args, Append_To (Args,
Make_Selected_Component (Loc, Make_Selected_Component (Loc,
Prefix => Prefix =>
......
...@@ -2525,14 +2525,14 @@ package body Freeze is ...@@ -2525,14 +2525,14 @@ package body Freeze is
end if; end if;
-- Deal with delayed aspect specifications. The analysis of the -- Deal with delayed aspect specifications. The analysis of the
-- aspect is required to be delayed to the freeze point, so we -- aspect is required to be delayed to the freeze point, thus we
-- evaluate the pragma or attribute definition clause in the tree at -- analyze the pragma or attribute definition clause in the tree at
-- this point. We also analyze the aspect specification node at the -- this point. We also analyze the aspect specification node at the
-- freeze point when the aspect doesn't correspond to -- freeze point when the aspect doesn't correspond to
-- pragma/attribute definition clause. -- pragma/attribute definition clause.
if Has_Delayed_Aspects (E) then if Has_Delayed_Aspects (E) then
Evaluate_Aspects_At_Freeze_Point (E); Analyze_Aspects_At_Freeze_Point (E);
end if; end if;
-- Here to freeze the entity -- Here to freeze the entity
......
...@@ -265,7 +265,6 @@ Implementation Defined Attributes ...@@ -265,7 +265,6 @@ Implementation Defined Attributes
* Mechanism_Code:: * Mechanism_Code::
* Null_Parameter:: * Null_Parameter::
* Object_Size:: * Object_Size::
* Old::
* Passed_By_Reference:: * Passed_By_Reference::
* Pool_Address:: * Pool_Address::
* Range_Length:: * Range_Length::
...@@ -6016,7 +6015,6 @@ consideration, you should minimize the use of these attributes. ...@@ -6016,7 +6015,6 @@ consideration, you should minimize the use of these attributes.
* Mechanism_Code:: * Mechanism_Code::
* Null_Parameter:: * Null_Parameter::
* Object_Size:: * Object_Size::
* Old::
* Passed_By_Reference:: * Passed_By_Reference::
* Pool_Address:: * Pool_Address::
* Range_Length:: * Range_Length::
...@@ -6627,53 +6625,6 @@ alignment will be 4, because of the ...@@ -6627,53 +6625,6 @@ alignment will be 4, because of the
integer field, and so the default size of record objects for this type integer field, and so the default size of record objects for this type
will be 64 (8 bytes). will be 64 (8 bytes).
@node Old
@unnumberedsec Old
@cindex Capturing Old values
@cindex Postconditions
@noindent
The attribute Prefix'Old can be used within a
subprogram body or within a precondition or
postcondition pragma. The effect is to
refer to the value of the prefix on entry. So for
example if you have an argument of a record type X called Arg1,
you can refer to Arg1.Field'Old which yields the value of
Arg1.Field on entry. The implementation simply involves generating
an object declaration which captures the value on entry.
The prefix must denote an object of a nonlimited type (since limited types
cannot be copied to capture their values) and it must not reference a local
variable (since local variables do not exist at subprogram entry time). Note
that the variable introduced by a quantified expression is a local variable.
The following example shows the use of 'Old to implement
a test of a postcondition:
@smallexample @c ada
with Old_Pkg;
procedure Old is
begin
Old_Pkg.Incr;
end Old;
package Old_Pkg is
procedure Incr;
end Old_Pkg;
package body Old_Pkg is
Count : Natural := 0;
procedure Incr is
begin
... code manipulating the value of Count
pragma Assert (Count = Count'Old + 1);
end Incr;
end Old_Pkg;
@end smallexample
@noindent
Note that it is allowed to apply 'Old to a constant entity, but this will
result in a warning, since the old and new values will always be the same.
@node Passed_By_Reference @node Passed_By_Reference
@unnumberedsec Passed_By_Reference @unnumberedsec Passed_By_Reference
@cindex Parameters, when passed by reference @cindex Parameters, when passed by reference
......
...@@ -439,9 +439,9 @@ db_phases (int phases) ...@@ -439,9 +439,9 @@ db_phases (int phases)
| |
+--> __gnat_personality_v0 (context, exception) +--> __gnat_personality_v0 (context, exception)
| |
+--> get_region_descriptor_for (context) +--> get_region_description_for (context)
| |
+--> get_action_descriptor_for (context, exception, region) +--> get_action_description_for (context, exception, region)
| | | |
| +--> get_call_site_action_for (context, region) | +--> get_call_site_action_for (context, region)
| (one version for each underlying scheme) | (one version for each underlying scheme)
...@@ -1019,7 +1019,6 @@ setup_to_install (_Unwind_Context *uw_context, ...@@ -1019,7 +1019,6 @@ setup_to_install (_Unwind_Context *uw_context,
automatic backtraces upon exception raise, as provided through the automatic backtraces upon exception raise, as provided through the
GNAT.Traceback facilities. */ GNAT.Traceback facilities. */
extern void __gnat_notify_handled_exception (void); extern void __gnat_notify_handled_exception (void);
extern void __gnat_notify_unhandled_exception (void);
/* Below is the eh personality routine per se. We currently assume that only /* Below is the eh personality routine per se. We currently assume that only
GNU-Ada exceptions are met. */ GNU-Ada exceptions are met. */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 2005-2011, Free Software Foundation, Inc. * * Copyright (C) 2005-2012, 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- *
...@@ -219,6 +219,9 @@ __gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord, ...@@ -219,6 +219,9 @@ __gnat_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
the loaded DLL (for example it results in unexpected behaviors in the the loaded DLL (for example it results in unexpected behaviors in the
Win32 subsystem. */ Win32 subsystem. */
#ifndef __SEH__
/* Don't use this trick when SEH are emitted by gcc, as it will conflict with
them. */
asm asm
( (
" .section .rdata, \"dr\"\n" " .section .rdata, \"dr\"\n"
...@@ -238,6 +241,7 @@ asm ...@@ -238,6 +241,7 @@ asm
"\n" "\n"
" .text\n" " .text\n"
); );
#endif /* __SEH__ */
void __gnat_install_SEH_handler (void *eh ATTRIBUTE_UNUSED) void __gnat_install_SEH_handler (void *eh ATTRIBUTE_UNUSED)
{ {
......
...@@ -3905,10 +3905,95 @@ package body Sem_Attr is ...@@ -3905,10 +3905,95 @@ package body Sem_Attr is
-- Old -- -- Old --
--------- ---------
when Attribute_Old => when Attribute_Old => Old : declare
CS : Entity_Id;
-- The enclosing scope, excluding loops for quantified expressions.
-- During analysis, it is the postcondition subprogram. During
-- pre-analysis, it is the scope of the subprogram declaration.
Prag : Node_Id;
-- During pre-analysis, Prag is the enclosing pragma node if any
begin
-- Find enclosing scopes, excluding loops
CS := Current_Scope;
while Ekind (CS) = E_Loop loop
CS := Scope (CS);
end loop;
-- The attribute reference is a primary. If expressions follow, the -- If we are in Spec_Expression mode, this should be the prescan of
-- attribute reference is an indexable object, so rewrite the node -- the postcondition (or contract case, or test case) pragma.
if In_Spec_Expression then
-- Check in postcondition or Ensures clause
Prag := N;
while not Nkind_In (Prag, N_Pragma,
N_Function_Specification,
N_Procedure_Specification,
N_Subprogram_Body)
loop
Prag := Parent (Prag);
end loop;
if Nkind (Prag) /= N_Pragma then
Error_Attr ("% attribute can only appear in postcondition", P);
elsif Get_Pragma_Id (Prag) = Pragma_Contract_Case
or else
Get_Pragma_Id (Prag) = Pragma_Test_Case
then
declare
Arg_Ens : constant Node_Id :=
Get_Ensures_From_CTC_Pragma (Prag);
Arg : Node_Id;
begin
Arg := N;
while Arg /= Prag and Arg /= Arg_Ens loop
Arg := Parent (Arg);
end loop;
if Arg /= Arg_Ens then
if Get_Pragma_Id (Prag) = Pragma_Contract_Case then
Error_Attr
("% attribute misplaced inside contract case", P);
else
Error_Attr
("% attribute misplaced inside test case", P);
end if;
end if;
end;
elsif Get_Pragma_Id (Prag) /= Pragma_Postcondition then
Error_Attr ("% attribute can only appear in postcondition", P);
end if;
-- Body case, where we must be inside a generated _Postcondition
-- procedure, or else the attribute use is definitely misplaced. The
-- postcondition itself may have generated transient scopes, and is
-- not necessarily the current one.
else
while Present (CS) and then CS /= Standard_Standard loop
if Chars (CS) = Name_uPostconditions then
exit;
else
CS := Scope (CS);
end if;
end loop;
if Chars (CS) /= Name_uPostconditions then
Error_Attr ("% attribute can only appear in postcondition", P);
end if;
end if;
-- Either the attribute reference is generated for a Requires
-- clause, in which case no expressions follow, or it is a
-- primary. In that case, if expressions follow, the attribute
-- reference is an indexable object, so rewrite the node
-- accordingly. -- accordingly.
if Present (E1) then if Present (E1) then
...@@ -3926,17 +4011,13 @@ package body Sem_Attr is ...@@ -3926,17 +4011,13 @@ package body Sem_Attr is
Check_E0; Check_E0;
-- Prefix has not been analyzed yet, and its full analysis will take -- Prefix has not been analyzed yet, and its full analysis will
-- place during expansion (see below). -- take place during expansion (see below).
Preanalyze_And_Resolve (P); Preanalyze_And_Resolve (P);
P_Type := Etype (P); P_Type := Etype (P);
Set_Etype (N, P_Type); Set_Etype (N, P_Type);
if No (Current_Subprogram) then
Error_Attr ("attribute % can only appear within subprogram", N);
end if;
if Is_Limited_Type (P_Type) then if Is_Limited_Type (P_Type) then
Error_Attr ("attribute % cannot apply to limited objects", P); Error_Attr ("attribute % cannot apply to limited objects", P);
end if; end if;
...@@ -3948,77 +4029,14 @@ package body Sem_Attr is ...@@ -3948,77 +4029,14 @@ package body Sem_Attr is
("?attribute Old applied to constant has no effect", P); ("?attribute Old applied to constant has no effect", P);
end if; end if;
-- Check that the expression does not refer to local entities
Check_Local : declare
Subp : Entity_Id := Current_Subprogram;
function Process (N : Node_Id) return Traverse_Result;
-- Check that N does not contain references to local variables or
-- other local entities of Subp.
-------------
-- Process --
-------------
function Process (N : Node_Id) return Traverse_Result is
begin
if Is_Entity_Name (N)
and then Present (Entity (N))
and then not Is_Formal (Entity (N))
and then Enclosing_Subprogram (Entity (N)) = Subp
then
Error_Msg_Node_1 := Entity (N);
Error_Attr
("attribute % cannot refer to local variable&", N);
end if;
return OK;
end Process;
procedure Check_No_Local is new Traverse_Proc;
-- Start of processing for Check_Local
begin
Check_No_Local (P);
if In_Parameter_Specification (P) then
-- We have additional restrictions on using 'Old in parameter
-- specifications.
if Present (Enclosing_Subprogram (Current_Subprogram)) then
-- Check that there is no reference to the enclosing
-- subprogram local variables. Otherwise, we might end up
-- being called from the enclosing subprogram and thus using
-- 'Old on a local variable which is not defined at entry
-- time.
Subp := Enclosing_Subprogram (Current_Subprogram);
Check_No_Local (P);
else
-- We must prevent default expression of library-level
-- subprogram from using 'Old, as the subprogram may be
-- used in elaboration code for which there is no enclosing
-- subprogram.
Error_Attr
("attribute % can only appear within subprogram", N);
end if;
end if;
end Check_Local;
-- The attribute appears within a pre/postcondition, but refers to -- The attribute appears within a pre/postcondition, but refers to
-- an entity in the enclosing subprogram. If it is a component of a -- an entity in the enclosing subprogram. If it is a component of
-- formal its expansion might generate actual subtypes that may be -- a formal its expansion might generate actual subtypes that may
-- referenced in an inner context, and which must be elaborated -- be referenced in an inner context, and which must be elaborated
-- within the subprogram itself. As a result we create a declaration -- within the subprogram itself. As a result we create a
-- for it and insert it at the start of the enclosing subprogram -- declaration for it and insert it at the start of the enclosing
-- This is properly an expansion activity but it has to be performed -- subprogram. This is properly an expansion activity but it has
-- now to prevent out-of-order issues. -- to be performed now to prevent out-of-order issues.
if Nkind (P) = N_Selected_Component if Nkind (P) = N_Selected_Component
and then Has_Discriminants (Etype (Prefix (P))) and then Has_Discriminants (Etype (Prefix (P)))
...@@ -4028,6 +4046,7 @@ package body Sem_Attr is ...@@ -4028,6 +4046,7 @@ package body Sem_Attr is
Set_Etype (P, P_Type); Set_Etype (P, P_Type);
Expand (N); Expand (N);
end if; end if;
end Old;
---------------------- ----------------------
-- Overlaps_Storage -- -- Overlaps_Storage --
...@@ -4261,9 +4280,9 @@ package body Sem_Attr is ...@@ -4261,9 +4280,9 @@ package body Sem_Attr is
end if; end if;
-- If we are in the scope of a function and in Spec_Expression mode, -- If we are in the scope of a function and in Spec_Expression mode,
-- this is likely the prescan of the postcondition pragma, and we -- this is likely the prescan of the postcondition (or contract case,
-- just set the proper type. If there is an error it will be caught -- or test case) pragma, and we just set the proper type. If there is
-- when the real Analyze call is done. -- an error it will be caught when the real Analyze call is done.
if Ekind (CS) = E_Function if Ekind (CS) = E_Function
and then In_Spec_Expression and then In_Spec_Expression
...@@ -4278,7 +4297,7 @@ package body Sem_Attr is ...@@ -4278,7 +4297,7 @@ package body Sem_Attr is
Error_Attr; Error_Attr;
end if; end if;
-- Check in postcondition of function -- Check in postcondition or Ensures clause of function
Prag := N; Prag := N;
while not Nkind_In (Prag, N_Pragma, while not Nkind_In (Prag, N_Pragma,
...@@ -4352,8 +4371,8 @@ package body Sem_Attr is ...@@ -4352,8 +4371,8 @@ package body Sem_Attr is
end if; end if;
-- Body case, where we must be inside a generated _Postcondition -- Body case, where we must be inside a generated _Postcondition
-- procedure, and the prefix must be on the scope stack, or else -- procedure, and the prefix must be on the scope stack, or else the
-- the attribute use is definitely misplaced. The condition itself -- attribute use is definitely misplaced. The postcondition itself
-- may have generated transient scopes, and is not necessarily the -- may have generated transient scopes, and is not necessarily the
-- current one. -- current one.
......
...@@ -299,6 +299,9 @@ package Sem_Ch13 is ...@@ -299,6 +299,9 @@ package Sem_Ch13 is
-- Quite an awkward procedure, but this is an awkard requirement! -- Quite an awkward procedure, but this is an awkard requirement!
procedure Analyze_Aspects_At_Freeze_Point (E : Entity_Id);
-- Analyze all the delayed aspects for entity E at freezing point
procedure Check_Aspect_At_Freeze_Point (ASN : Node_Id); procedure Check_Aspect_At_Freeze_Point (ASN : Node_Id);
-- Performs the processing described above at the freeze point, ASN is the -- Performs the processing described above at the freeze point, ASN is the
-- N_Aspect_Specification node for the aspect. -- N_Aspect_Specification node for the aspect.
...@@ -307,7 +310,4 @@ package Sem_Ch13 is ...@@ -307,7 +310,4 @@ package Sem_Ch13 is
-- Performs the processing described above at the freeze all point, and -- Performs the processing described above at the freeze all point, and
-- issues appropriate error messages if the visibility has indeed changed. -- issues appropriate error messages if the visibility has indeed changed.
-- Again, ASN is the N_Aspect_Specification node for the aspect. -- Again, ASN is the N_Aspect_Specification node for the aspect.
procedure Evaluate_Aspects_At_Freeze_Point (E : Entity_Id);
-- Evaluates all the delayed aspects for entity E at freezing point
end Sem_Ch13; end Sem_Ch13;
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