diff options
author | Robert Dewar <dewar@adacore.com> | 2007-08-14 10:45:25 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-08-14 10:45:25 +0200 |
commit | b11e8d6fc0722f739630bfabff7d778faae9f1d3 (patch) | |
tree | 7f1f9f1c3411501de6576d01a74c4d83f635c7a1 /gcc/ada/sem.ads | |
parent | 9410151a22e5a54497fcc44bf30dccf3569441e0 (diff) | |
download | gcc-b11e8d6fc0722f739630bfabff7d778faae9f1d3.zip gcc-b11e8d6fc0722f739630bfabff7d778faae9f1d3.tar.gz gcc-b11e8d6fc0722f739630bfabff7d778faae9f1d3.tar.bz2 |
s-intman-irix.adb, [...]: Minor reformatting
2007-08-14 Robert Dewar <dewar@adacore.com>
* s-intman-irix.adb, s-osinte-irix.adb, s-osinte-irix.ads,
s-proinf-irix-athread.ads, s-osinte-hpux-dce.adb, s-osinte-hpux-dce.ads,
s-parame-hpux.ads, s-intman-dummy.adb, s-tasinf-solaris.adb,
s-tasinf-solaris.ads, s-asthan-vms-alpha.adb, s-inmaop-vms.adb,
s-intman-vms.adb, s-intman-vms.ads, s-osprim-mingw.adb,
s-parame-vms-restrict.ads, s-parame-ae653.ads, s-intman-vxworks.ads,
s-intman-vxworks.ads, s-intman-vxworks.adb, s-parame-vxworks.ads,
s-tfsetr-vxworks.adb, s-interr.adb, s-interr.ads, a-tasatt.adb,
exp_ch13.adb, s-htable.ads, s-imgboo.ads, s-imglli.ads, s-imgllu.ads,
s-imguns.ads, g-eacodu.adb, par-ch12.adb, s-stache.ads, s-stausa.adb,
s-poosiz.adb, s-parame.ads, s-mastop.ads, s-osinte-darwin.ads,
a-chtgke.adb, s-asthan-vms-alpha.adb, s-parame-vms-alpha.ads,
s-parame-vms-ia64.ads, s-parame-vxworks.adb, s-except.ads,
g-altcon.adb: Minor reformatting
ada-tree.h: Delete empty line.
ali.ads: Minor reformatting
Clarification of comments.
Minor spelling correction
* exp_dbug.adb: Add Warnings Off to suppress new warning
* a-witeio.adb (Write): Add Warnings (Off) for unneeded IN OUT mode
formal
* a-strunb.adb (Set_Unbounded_String): Avoid memory leak by freeing old
value
* a-textio.adb (Write): Remove an unnecessary IN OUT mode from
* a-textio.ads: Reorder the standard input/output/error declarations
for consistency.
* g-dirope.adb, g-dirope.ads: Change Dir to mode IN for Open call
* par-ch2.adb: Recognize RM specially in errout
Change 'R'M to RM in all error messages
* scng.adb: Recognize RM specially in errout
* sem.ads, sem.adb, exp_strm.adb, exp_ch5.ads, expander.adb: Rename
N_Return node to be N_Simple_Return, to reflect Ada 2005 terminology.
* s-direio.adb: Add missing routine header box.
* sem_attr.ads: Add ??? comments
* sem_eval.adb: Recognize RM specially in errout
Change 'R'M to RM in all error messages
* sem_maps.adb, sem_maps.ads: Remove some unnecessary IN OUT modes
* s-tasinf.ads: Fix minor comment typo.
* a-cihama.adb: Minor comment addition
* a-ztexio.adb (Write): Add Warnings (Off) for unneeded IN OUT mode
formal
* s-tasinf-tru64.ads: Fix minor comment typo.
* itypes.ads: Comment update.
* ali-util.adb: Remove Generic_Separately_Compiled guard, not needed
anymore.
* argv.c: Added protection against null gnat_argv and gnat_envp.
* bcheck.adb (Check_Consistency): Use correct markup character ({) in
warning message when Tolerate_Consistency_Errors is True.
* cstand.adb (Create_Standard): Do not call Init_Size_Alignment for
Any_Id, as this subprogram is only applicable to *type* entities (it
sets RM_Size). Instead initialize just Esize and Alignment.
From-SVN: r127440
Diffstat (limited to 'gcc/ada/sem.ads')
-rw-r--r-- | gcc/ada/sem.ads | 238 |
1 files changed, 134 insertions, 104 deletions
diff --git a/gcc/ada/sem.ads b/gcc/ada/sem.ads index 8b38c33..241ea5a 100644 --- a/gcc/ada/sem.ads +++ b/gcc/ada/sem.ads @@ -211,26 +211,27 @@ package Sem is ----------------------------- Full_Analysis : Boolean := True; - -- Switch to indicate whether we are doing a full analysis or a - -- pre-analysis. In normal analysis mode (Analysis-Expansion for - -- instructions or declarations) or (Analysis-Resolution-Expansion for - -- expressions) this flag is set. Note that if we are not generating - -- code the expansion phase merely sets the Analyzed flag to True in - -- this case. If we are in Pre-Analysis mode (see above) this flag is - -- set to False then the expansion phase is skipped. - -- When this flag is False the flag Expander_Active is also False - -- (the Expander_Activer flag defined in the spec of package Expander - -- tells you whether expansion is currently enabled). - -- You should really regard this as a read only flag. + -- Switch to indicate if we are doing a full analysis or a pre-analysis. + -- In normal analysis mode (Analysis-Expansion for instructions or + -- declarations) or (Analysis-Resolution-Expansion for expressions) this + -- flag is set. Note that if we are not generating code the expansion phase + -- merely sets the Analyzed flag to True in this case. If we are in + -- Pre-Analysis mode (see above) this flag is set to False then the + -- expansion phase is skipped. + -- + -- When this flag is False the flag Expander_Active is also False (the + -- Expander_Activer flag defined in the spec of package Expander tells you + -- whether expansion is currently enabled). You should really regard this + -- as a read only flag. In_Default_Expression : Boolean := False; -- Switch to indicate that we are in a default expression, as described -- above. Note that this must be recursively saved on a Semantics call - -- since it is possible for the analysis of an expression to result in - -- a recursive call (e.g. to get the entity for System.Address as part - -- of the processing of an Address attribute reference). - -- When this switch is True then Full_Analysis above must be False. - -- You should really regard this as a read only flag. + -- since it is possible for the analysis of an expression to result in a + -- recursive call (e.g. to get the entity for System.Address as part of the + -- processing of an Address attribute reference). When this switch is True + -- then Full_Analysis above must be False. You should really regard this as + -- a read only flag. In_Deleted_Code : Boolean := False; -- If the condition in an if-statement is statically known, the branch @@ -259,6 +260,121 @@ package Sem is -- about unused variables, since these warnings are unreliable in this -- case. We could perhaps do a more accurate job and retain some of the -- warnings, but it is quite a tricky job. See test 4323-002. + -- Should not reference TN's in the source comments ??? + + ----------------------------------- + -- Handling of Check Suppression -- + ----------------------------------- + + -- There are two kinds of suppress checks: scope based suppress checks, + -- and entity based suppress checks. + + -- Scope based suppress checks for the predefined checks (from initial + -- command line arguments, or from Suppress pragmas not including an entity + -- entity name) are recorded in the Sem.Supress variable, and all that is + -- necessary is to save the state of this variable on scope entry, and + -- restore it on scope exit. This mechanism allows for fast checking of + -- the scope suppress state without needing complex data structures. + + -- Entity based checks, from Suppress/Unsuppress pragmas giving an + -- Entity_Id and scope based checks for non-predefined checks (introduced + -- using pragma Check_Name), are handled as follows. If a suppress or + -- unsuppress pragma is encountered for a given entity, then the flag + -- Checks_May_Be_Suppressed is set in the entity and an entry is made in + -- either the Local_Entity_Suppress stack (case of pragma that appears in + -- other than a package spec), or in the Global_Entity_Suppress stack (case + -- of pragma that appears in a package spec, which is by the rule of RM + -- 11.5(7) applicable throughout the life of the entity). Similarly, a + -- Suppress/Unsuppress pragma for a non-predefined check which does not + -- specify an entity is also stored in one of these stacks. + + -- If the Checks_May_Be_Suppressed flag is set in an entity then the + -- procedure is to search first the local and then the global suppress + -- stacks (we search these in reverse order, top element first). The only + -- other point is that we have to make sure that we have proper nested + -- interaction between such specific pragmas and locally applied general + -- pragmas applying to all entities. This is achieved by including in the + -- Local_Entity_Suppress table dummy entries with an empty Entity field + -- that are applicable to all entities. A similar search is needed for any + -- non-predefined check even if no specific entity is involved. + + Scope_Suppress : Suppress_Array := Suppress_Options; + -- This array contains the current scope based settings of the suppress + -- switches. It is initialized from the options as shown, and then modified + -- by pragma Suppress. On entry to each scope, the current setting is saved + -- the scope stack, and then restored on exit from the scope. This record + -- may be rapidly checked to determine the current status of a check if + -- no specific entity is involved or if the specific entity involved is + -- one for which no specific Suppress/Unsuppress pragma has been set (as + -- indicated by the Checks_May_Be_Suppressed flag being set). + + -- This scheme is a little complex, but serves the purpose of enabling + -- a very rapid check in the common case where no entity specific pragma + -- applies, and gives the right result when such pragmas are used even + -- in complex cases of nested Suppress and Unsuppress pragmas. + + -- The Local_Entity_Suppress and Global_Entity_Suppress stacks are handled + -- using dynamic allocation and linked lists. We do not often use this + -- approach in the compiler (preferring to use extensible tables instead). + -- The reason we do it here is that scope stack entries save a pointer to + -- the current local stack top, which is also saved and restored on scope + -- exit. Furthermore for processing of generics we save pointers to the + -- top of the stack, so that the local stack is actually a tree of stacks + -- rather than a single stack, a structure that is easy to represent using + -- linked lists, but impossible to represent using a single table. Note + -- that because of the generic issue, we never release entries in these + -- stacks, but that's no big deal, since we are unlikely to have a huge + -- number of Suppress/Unsuppress entries in a single compilation. + + type Suppress_Stack_Entry; + type Suppress_Stack_Entry_Ptr is access all Suppress_Stack_Entry; + + type Suppress_Stack_Entry is record + Entity : Entity_Id; + -- Entity to which the check applies, or Empty for a check that has + -- no entity name (and thus applies to all entities). + + Check : Check_Id; + -- Check which is set (can be All_Checks for the All_Checks case) + + Suppress : Boolean; + -- Set True for Suppress, and False for Unsuppress + + Prev : Suppress_Stack_Entry_Ptr; + -- Pointer to previous entry on stack + + Next : Suppress_Stack_Entry_Ptr; + -- All allocated Suppress_Stack_Entry records are chained together in + -- a linked list whose head is Suppress_Stack_Entries, and the Next + -- field is used as a forward pointer (null ends the list). This is + -- used to free all entries in Sem.Init (which will be important if + -- we ever setup the compiler to be reused). + end record; + + Suppress_Stack_Entries : Suppress_Stack_Entry_Ptr := null; + -- Pointer to linked list of records (see comments for Next above) + + Local_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr; + -- Pointer to top element of local suppress stack. This is the entry that + -- is saved and restored in the scope stack, and also saved for generic + -- body expansion. + + Global_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr; + -- Pointer to top element of global suppress stack + + procedure Push_Local_Suppress_Stack_Entry + (Entity : Entity_Id; + Check : Check_Id; + Suppress : Boolean); + -- Push a new entry on to the top of the local suppress stack, updating + -- the value in Local_Suppress_Stack_Top; + + procedure Push_Global_Suppress_Stack_Entry + (Entity : Entity_Id; + Check : Check_Id; + Suppress : Boolean); + -- Push a new entry on to the top of the global suppress stack, updating + -- the value in Global_Suppress_Stack_Top; ----------------- -- Scope Stack -- @@ -324,8 +440,8 @@ package Sem is Save_Scope_Suppress : Suppress_Array; -- Save contents of Scope_Suppress on entry - Save_Local_Entity_Suppress : Int; - -- Save contents of Local_Entity_Suppress.Last on entry + Save_Local_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr; + -- Save contents of Local_Suppress_Stack on entry to restore on exit Is_Transient : Boolean; -- Marks Transient Scopes (See Exp_Ch7 body for details) @@ -383,92 +499,6 @@ package Sem is Table_Increment => Alloc.Scope_Stack_Increment, Table_Name => "Sem.Scope_Stack"); - ----------------------------------- - -- Handling of Check Suppression -- - ----------------------------------- - - -- There are two kinds of suppress checks: scope based suppress checks, - -- and entity based suppress checks. - - -- Scope based suppress checks (from initial command line arguments, - -- or from Suppress pragmas not including an entity name) are recorded - -- in the Sem.Supress variable, and all that is necessary is to save the - -- state of this variable on scope entry, and restore it on scope exit. - - -- Entity based suppress checks, from Suppress pragmas giving an Entity_Id, - -- are handled as follows. If a suppress or unsuppress pragma is - -- encountered for a given entity, then the flag Checks_May_Be_Suppressed - -- is set in the entity and an entry is made in either the - -- Local_Entity_Suppress table (case of pragma that appears in other than - -- a package spec), or in the Global_Entity_Suppress table (case of pragma - -- that appears in a package spec, which is by the rule of RM 11.5(7) - -- applicable throughout the life of the entity). - - -- If the Checks_May_Be_Suppressed flag is set in an entity then the - -- procedure is to search first the local and then the global suppress - -- tables (the local one being searched in reverse order, i.e. last in - -- searched first). The only other point is that we have to make sure - -- that we have proper nested interaction between such specific pragmas - -- and locally applied general pragmas applying to all entities. This - -- is achieved by including in the Local_Entity_Suppress table dummy - -- entries with an empty Entity field that are applicable to all entities. - - Scope_Suppress : Suppress_Array := Suppress_Options; - -- This array contains the current scope based settings of the suppress - -- switches. It is initialized from the options as shown, and then modified - -- by pragma Suppress. On entry to each scope, the current setting is saved - -- the scope stack, and then restored on exit from the scope. This record - -- may be rapidly checked to determine the current status of a check if - -- no specific entity is involved or if the specific entity involved is - -- one for which no specific Suppress/Unsuppress pragma has been set (as - -- indicated by the Checks_May_Be_Suppressed flag being set). - - -- This scheme is a little complex, but serves the purpose of enabling - -- a very rapid check in the common case where no entity specific pragma - -- applies, and gives the right result when such pragmas are used even - -- in complex cases of nested Suppress and Unsuppress pragmas. - - type Entity_Check_Suppress_Record is record - Entity : Entity_Id; - -- Entity to which the check applies, or Empty for a local check - -- that has no entity name (and thus applies to all entities). - - Check : Check_Id; - -- Check which is set (note this cannot be All_Checks, if the All_Checks - -- case, a sequence of eentries appears for the individual checks. - - Suppress : Boolean; - -- Set True for Suppress, and False for Unsuppress - end record; - - -- The Local_Entity_Suppress table is a stack, to which new entries are - -- added for Suppress and Unsuppress pragmas appearing in other than - -- package specs. Such pragmas are effective only to the end of the scope - -- in which they appear. This is achieved by marking the stack on entry - -- to a scope and then cutting back the stack to that marked point on - -- scope exit. - - package Local_Entity_Suppress is new Table.Table ( - Table_Component_Type => Entity_Check_Suppress_Record, - Table_Index_Type => Int, - Table_Low_Bound => 0, - Table_Initial => Alloc.Entity_Suppress_Initial, - Table_Increment => Alloc.Entity_Suppress_Increment, - Table_Name => "Local_Entity_Suppress"); - - -- The Global_Entity_Suppress table is used for entities which have - -- a Suppress or Unsuppress pragma naming a specific entity in a - -- package spec. Such pragmas always refer to entities in the package - -- spec and are effective throughout the lifetime of the named entity. - - package Global_Entity_Suppress is new Table.Table ( - Table_Component_Type => Entity_Check_Suppress_Record, - Table_Index_Type => Int, - Table_Low_Bound => 0, - Table_Initial => Alloc.Entity_Suppress_Initial, - Table_Increment => Alloc.Entity_Suppress_Increment, - Table_Name => "Global_Entity_Suppress"); - ----------------- -- Subprograms -- ----------------- |