summaryrefslogtreecommitdiff
path: root/gcc/ada/aspects.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-10 14:54:41 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-10 14:54:41 +0000
commit37c6e44c944d1ee408049d929f5fe36f5f6d81fb (patch)
tree20f2e2ec7f0d0e8cdceee063a7ca0931e90c5c14 /gcc/ada/aspects.ads
parente5e512c52ff19986ad4ace0092b97d1a05b87566 (diff)
downloadgcc-37c6e44c944d1ee408049d929f5fe36f5f6d81fb.tar.gz
2013-09-10 Robert Dewar <dewar@adacore.com>
* aspects.ads (Delay_Type): New type (Aspect_Delay): New table. * einfo.adb (Has_Delayed_Rep_Aspects): New flag (May_Inherit_Delayed_Rep_Aspects): New flag (Rep_Clause): Removed (use Get_Attribute_Representation_Clause). * einfo.ads (Has_Delayed_Rep_Aspects): New flag (May_Inherit_Delayed_Rep_Aspects): New flag * freeze.adb: Minor reformatting * sem_ch13.adb (Analyze_Aspect_Speficifications): Redo handling of delayed evaluation, including optimizing some cases and avoiding delays. (Analyze_Aspects_At_Freeze_Point): Now handled inheriting delayed rep aspects for type derivation case. (Inherit_Delayed_Rep_Aspects): New procedure * sem_ch13.ads (Analyze_Aspects_At_Freeze_Point): Now handled inheriting delayed rep aspects for type derivation case. * sem_ch3.adb (Build_Derived_Type): Set May_Inherit_Derived_Rep_Aspects if parent type flag Has_Delayed_Rep_Aspects is set 2013-09-10 Robert Dewar <dewar@adacore.com> * errout.adb (Finalize): Don't delete real errors with specific warning control. 2013-09-10 Ed Schonberg <schonberg@adacore.com> * exp_ch9.adb (Expand_N_Timed_Entry_Call, Expand_N_Conditional_Entry_Call, Expand_N_Asynchronous_Select): Handle properly a trigger that is a call to a primitive operation of a type that implements a limited interface, if the type itself is not limited. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202456 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/aspects.ads')
-rw-r--r--gcc/ada/aspects.ads197
1 files changed, 197 insertions, 0 deletions
diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads
index 5a093af21cf..a7429d79119 100644
--- a/gcc/ada/aspects.ads
+++ b/gcc/ada/aspects.ads
@@ -459,6 +459,203 @@ package Aspects is
-- Given an aspect specification, return the corresponding aspect_id value.
-- If the name does not match any aspect, return No_Aspect.
+ ------------------------------------
+ -- Delaying Evaluation of Aspects --
+ ------------------------------------
+
+ -- The RM requires that all language defined aspects taking an expression
+ -- delay evaluation of the expression till the freeze point of the entity
+ -- to which the aspect applies. This allows forward references, and is of
+ -- use for example in connection with preconditions and postconditions
+ -- where the requirement of making all references in contracts to local
+ -- functions be backwards references would be onerous.
+
+ -- For consistency, even attributes like Size are delayed, so we can do:
+
+ -- type A is range 1 .. 10
+ -- with Size => Not_Defined_Yet;
+ -- ..
+ -- Not_Defined_Yet : constant := 64;
+
+ -- Resulting in A having a size of 64, which gets set when A is frozen.
+ -- Furthermore, we can have a situation like
+
+ -- type A is range 1 .. 10
+ -- with Size => Not_Defined_Yet;
+ -- ..
+ -- type B is new A;
+ -- ..
+ -- Not_Defined_Yet : constant := 64;
+
+ -- where the Size of A is considered to have been previously specified at
+ -- the point of derivation, even though the actual value of the size is
+ -- not known yet, and in this example B inherits the size value of 64.
+
+ -- Our normal implementation model (prior to Ada 2012) was simply to copy
+ -- inheritable attributes at the point of derivation. Then any subsequent
+ -- representation items apply either to the parent type, not affecting the
+ -- derived type, or to the derived type, not affecting the parent type.
+
+ -- To deal with the delayed aspect case, we use two flags. The first is
+ -- set on the parent type if it has delayed representation aspects. This
+ -- flag Has_Delayed_Rep_Aspects indicates that if we derive from this type
+ -- we have to worry about making sure we inherit any delayed types. The
+ -- second flag is set on a derived type. May_Have_Inherited_Rep_Aspects
+ -- is set if the parent type has Has_Delayed_Rep_Aspects set.
+
+ -- When we freeze a derived type, if the May_Have_Inherited_Rep_Aspects
+ -- flag is set, then we call Freeze.Inherit_Delayed_Rep_Aspects when
+ -- the derived type is frozen, which deals with the necessary copying of
+ -- information from the parent type, which must be frozen at that point
+ -- (since freezing the derived type first freezes the parent type).
+
+ -- The following shows which aspects are delayed. There are three cases:
+
+ type Delay_Type is
+ (Always_Delay,
+ -- This aspect is not a representation aspect that can be inherited and
+ -- is always delayed, as required by the language definition.
+
+ Never_Delay,
+ -- There are two cases. There are language defined attributes like
+ -- Convention where the "expression" is simply an uninterprted
+ -- identifier, and there is no issue of evaluating it and thus no
+ -- issue of delaying the evaluation. The second case is implementation
+ -- defined attributes where we have decided that we don't want to
+ -- allow delays (and for our own attributes we can do what we like!)
+
+ Rep_Aspect);
+ -- These are the cases of representation aspects that are in general
+ -- delayed, and where there is a potential issue of derived types that
+ -- inherit delayed representation values
+
+ -- Note: even if this table indicates that an aspect is delayed, we never
+ -- delay Boolean aspects that have a missing expression (taken as True),
+ -- or expressions for delayed rep items that consist of an integer literal
+ -- (most cases of Size etc. in practice), since in these cases we know we
+ -- can get the value of the expression without delay. Note that we still
+ -- need to delay Boolean aspects that are specifically set to True:
+
+ -- type R is array (0 .. 31) of Boolean
+ -- with Pack => True;
+ -- True : constant Boolean := False;
+
+ -- This is nonsense, but we need to make it work and result in R not
+ -- being packed, and if we have something like:
+
+ -- type R is array (0 .. 31) of Boolean
+ -- with Pack => True;
+ -- RR : R;
+ -- True : constant Boolean := False;
+
+ -- This is illegal because the visibility of True changes after the freeze
+ -- point, which is not allowed, and we need the delay mechanism to properly
+ -- diagnose this error.
+
+ Aspect_Delay : constant array (Aspect_Id) of Delay_Type :=
+ (No_Aspect => Always_Delay,
+ Aspect_Address => Always_Delay,
+ Aspect_All_Calls_Remote => Always_Delay,
+ Aspect_Asynchronous => Always_Delay,
+ Aspect_Attach_Handler => Always_Delay,
+ Aspect_Compiler_Unit => Always_Delay,
+ Aspect_Constant_Indexing => Always_Delay,
+ Aspect_Contract_Cases => Always_Delay,
+ Aspect_CPU => Always_Delay,
+ Aspect_Default_Iterator => Always_Delay,
+ Aspect_Default_Value => Always_Delay,
+ Aspect_Default_Component_Value => Always_Delay,
+ Aspect_Depends => Always_Delay,
+ Aspect_Discard_Names => Always_Delay,
+ Aspect_Dispatching_Domain => Always_Delay,
+ Aspect_Dynamic_Predicate => Always_Delay,
+ Aspect_Elaborate_Body => Always_Delay,
+ Aspect_External_Name => Always_Delay,
+ Aspect_External_Tag => Always_Delay,
+ Aspect_Export => Always_Delay,
+ Aspect_Favor_Top_Level => Always_Delay,
+ Aspect_Global => Always_Delay,
+ Aspect_Implicit_Dereference => Always_Delay,
+ Aspect_Import => Always_Delay,
+ Aspect_Independent => Always_Delay,
+ Aspect_Independent_Components => Always_Delay,
+ Aspect_Inline => Always_Delay,
+ Aspect_Inline_Always => Always_Delay,
+ Aspect_Input => Always_Delay,
+ Aspect_Interrupt_Handler => Always_Delay,
+ Aspect_Interrupt_Priority => Always_Delay,
+ Aspect_Invariant => Always_Delay,
+ Aspect_Iterator_Element => Always_Delay,
+ Aspect_Link_Name => Always_Delay,
+ Aspect_Lock_Free => Always_Delay,
+ Aspect_No_Return => Always_Delay,
+ Aspect_Output => Always_Delay,
+ Aspect_Persistent_BSS => Always_Delay,
+ Aspect_Post => Always_Delay,
+ Aspect_Postcondition => Always_Delay,
+ Aspect_Pre => Always_Delay,
+ Aspect_Precondition => Always_Delay,
+ Aspect_Predicate => Always_Delay,
+ Aspect_Preelaborable_Initialization => Always_Delay,
+ Aspect_Preelaborate => Always_Delay,
+ Aspect_Preelaborate_05 => Always_Delay,
+ Aspect_Priority => Always_Delay,
+ Aspect_Pure => Always_Delay,
+ Aspect_Pure_05 => Always_Delay,
+ Aspect_Pure_12 => Always_Delay,
+ Aspect_Pure_Function => Always_Delay,
+ Aspect_Read => Always_Delay,
+ Aspect_Relative_Deadline => Always_Delay,
+ Aspect_Remote_Access_Type => Always_Delay,
+ Aspect_Remote_Call_Interface => Always_Delay,
+ Aspect_Remote_Types => Always_Delay,
+ Aspect_Shared => Always_Delay,
+ Aspect_Shared_Passive => Always_Delay,
+ Aspect_Simple_Storage_Pool => Always_Delay,
+ Aspect_Simple_Storage_Pool_Type => Always_Delay,
+ Aspect_Static_Predicate => Always_Delay,
+ Aspect_Storage_Pool => Always_Delay,
+ Aspect_Stream_Size => Always_Delay,
+ Aspect_Suppress => Always_Delay,
+ Aspect_Suppress_Debug_Info => Always_Delay,
+ Aspect_Type_Invariant => Always_Delay,
+ Aspect_Unchecked_Union => Always_Delay,
+ Aspect_Universal_Aliasing => Always_Delay,
+ Aspect_Universal_Data => Always_Delay,
+ Aspect_Unmodified => Always_Delay,
+ Aspect_Unreferenced => Always_Delay,
+ Aspect_Unreferenced_Objects => Always_Delay,
+ Aspect_Unsuppress => Always_Delay,
+ Aspect_Variable_Indexing => Always_Delay,
+ Aspect_Write => Always_Delay,
+
+ Aspect_Abstract_State => Never_Delay,
+ Aspect_Ada_2005 => Never_Delay,
+ Aspect_Ada_2012 => Never_Delay,
+ Aspect_Convention => Never_Delay,
+ Aspect_Dimension => Never_Delay,
+ Aspect_Dimension_System => Never_Delay,
+ Aspect_SPARK_Mode => Never_Delay,
+ Aspect_Synchronization => Never_Delay,
+ Aspect_Test_Case => Never_Delay,
+ Aspect_Warnings => Never_Delay,
+
+ Aspect_Alignment => Rep_Aspect,
+ Aspect_Atomic => Rep_Aspect,
+ Aspect_Atomic_Components => Rep_Aspect,
+ Aspect_Bit_Order => Rep_Aspect,
+ Aspect_Component_Size => Rep_Aspect,
+ Aspect_Machine_Radix => Rep_Aspect,
+ Aspect_Object_Size => Rep_Aspect,
+ Aspect_Pack => Rep_Aspect,
+ Aspect_Scalar_Storage_Order => Rep_Aspect,
+ Aspect_Size => Rep_Aspect,
+ Aspect_Small => Rep_Aspect,
+ Aspect_Storage_Size => Rep_Aspect,
+ Aspect_Value_Size => Rep_Aspect,
+ Aspect_Volatile => Rep_Aspect,
+ Aspect_Volatile_Components => Rep_Aspect);
+
---------------------------------------------------
-- Handling of Aspect Specifications in the Tree --
---------------------------------------------------