diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2015-01-07 08:41:47 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-01-07 09:41:47 +0100 |
commit | 8636f52f7b50176948646cc151bfd514b8b71c03 (patch) | |
tree | 39cc0e2d60bd238be63e41b7c58c3559dddab13f /gcc/ada/ghost.ads | |
parent | 4a9a42abc4f30bd63ef666e972dcbce0f05f0d0d (diff) | |
download | gcc-8636f52f7b50176948646cc151bfd514b8b71c03.zip gcc-8636f52f7b50176948646cc151bfd514b8b71c03.tar.gz gcc-8636f52f7b50176948646cc151bfd514b8b71c03.tar.bz2 |
2015-01-07 Hristian Kirtchev <kirtchev@adacore.com>
* alloc.ads Alphabetize several declarations. Add constants
Ignored_Ghost_Units_Initial and Ignored_Ghost_Units_Increment.
* atree.adb Add with and use clauses for Opt.
(Allocate_Initialize_Node): Mark a node as ignored Ghost
if it is created in an ignored Ghost region.
(Ekind_In): New variant.
(Is_Ignored_Ghost_Node): New routine.
(Set_Is_Ignored_Ghost_Node): New routine.
* atree.adb Aplhabetize several subprograms declarations. Flag
Spare0 is now known as Is_Ignored_Ghost_Node.
(Ekind_In): New variant.
(Is_Ignored_Ghost_Node): New routine.
(Set_Is_Ignored_Ghost_Node): New routine.
* einfo.adb: Flag 279 is now known as Contains_Ignored_Ghost_Code.
(Contains_Ignored_Ghost_Code): New routine.
(Set_Contains_Ignored_Ghost_Code): New routine.
(Set_Is_Checked_Ghost_Entity, Set_Is_Ignored_Ghost_Entity):
It is now possible to set this property on an unanalyzed entity.
(Write_Entity_Flags): Output the status of flag
Contains_Ignored_Ghost_Code.
* einfo.ads New attribute Contains_Ignored_Ghost_Code along with
usage in nodes.
(Contains_Ignored_Ghost_Code): New routine
along with pragma Inline.
(Set_Contains_Ignored_Ghost_Code): New routine along with pragma Inline.
* exp_ch3.adb Add with and use clauses for Ghost.
(Freeze_Type): Capture/restore the value of Ghost_Mode on entry/exit.
Set the Ghost_Mode in effect.
(Restore_Globals): New routine.
* exp_ch7.adb (Process_Declarations): Do not process a context
that invoves an ignored Ghost entity.
* exp_dbug.adb (Qualify_All_Entity_Names): Skip an ignored Ghost
construct that has been rewritten as a null statement.
* exp_disp.adb Add with and use clauses for Ghost.
(Make_DT): Capture/restore the value of Ghost_Mode on entry/exit. Set
the Ghost_Mode in effect.
(Restore_Globals): New routine.
* exp_util.adb (Requires_Cleanup_Actions): An ignored Ghost entity
does not require any clean up. Add two missing cases that deal
with block statements.
* freeze.adb Add with and use clauses for Ghost.
(Freeze_Entity): Capture/restore the value of Ghost_Mode on entry/exit.
Set the Ghost_Mode in effect.
(Restore_Globals): New routine.
* frontend.adb Add with and use clauses for Ghost. Remove any
ignored Ghost code from all units that qualify.
* ghost.adb New unit.
* ghost.ads New unit.
* gnat1drv.adb Add with clause for Ghost. Initialize and lock
the table in package Ghost.
* lib.ads: Alphabetize several subprogram declarations.
* lib-xref.adb (Output_References): Do not generate reference
information for ignored Ghost entities.
* opt.ads Add new type Ghost_Mode_Type and new global variable
Ghost_Mode.
* rtsfind.adb (Load_RTU): Provide a clean environment when
loading a runtime unit.
* sem.adb (Analyze): Capture/restore the value of Ghost_Mode on
entry/exit as the node may set a different mode.
(Do_Analyze):
Capture/restore the value of Ghost_Mode on entry/exit as the
unit may be withed from a unit with a different Ghost mode.
* sem_ch3.adb Add with and use clauses for Ghost.
(Analyze_Full_Type_Declaration, Analyze_Incomplete_Type_Decl,
Analyze_Number_Declaration, Analyze_Private_Extension_Declaration,
Analyze_Subtype_Declaration): Set the Ghost_Mode in effect. Mark
the entity as Ghost when there is a Ghost_Mode in effect.
(Array_Type_Declaration): The implicit base type inherits the
"ghostness" from the array type.
(Derive_Subprogram): The
alias inherits the "ghostness" from the parent subprogram.
(Make_Implicit_Base): The implicit base type inherits the
"ghostness" from the parent type.
* sem_ch5.adb Add with and use clauses for Ghost.
(Analyze_Assignment): Set the Ghost_Mode in effect.
* sem_ch6.adb Add with and use clauses for Ghost.
(Analyze_Abstract_Subprogram_Declaration, Analyze_Procedure_Call,
Analyze_Subprogram_Body_Helper, Analyze_Subprogram_Declaration):
Set the Ghost_Mode in effect. Mark the entity as Ghost when
there is a Ghost_Mode in effect.
* sem_ch7.adb Add with and use clauses for Ghost.
(Analyze_Package_Body_Helper, Analyze_Package_Declaration,
Analyze_Private_Type_Declaration): Set the Ghost_Mode in
effect. Mark the entity as Ghost when there is a Ghost_Mode
in effect.
* sem_ch8.adb Add with and use clauses for Ghost.
(Analyze_Exception_Renaming, Analyze_Generic_Renaming,
Analyze_Object_Renaming, Analyze_Package_Renaming,
Analyze_Subprogram_Renaming): Set the Ghost_Mode in effect. Mark
the entity as Ghost when there is a Ghost_Mode in effect.
(Find_Type): Check the Ghost context of a type.
* sem_ch11.adb Add with and use clauses for Ghost.
(Analyze_Exception_Declaration): Set the Ghost_Mode in
effect. Mark the entity as Ghost when there is a Ghost_Mode
in effect.
* sem_ch12.adb Add with and use clauses for Ghost.
(Analyze_Generic_Package_Declaration,
Analyze_Generic_Subprogram_Declaration): Set the Ghost_Mode in effect.
Mark the entity as Ghost when there is a Ghost_Mode in effect.
* sem_prag.adb Add with and use clauses for Ghost.
(Analyze_Pragma): Ghost-related checks are triggered when there
is a Ghost mode in effect.
(Create_Abstract_State): Mark the
entity as Ghost when there is a Ghost_Mode in effect.
* sem_res.adb Add with and use clauses for Ghost.
(Check_Ghost_Context): Removed.
* sem_util.adb (Check_Ghost_Completion): Removed.
(Check_Ghost_Derivation): Removed.
(Incomplete_Or_Partial_View):
Add a guard in case the entity has not been analyzed yet
and does carry a scope.
(Is_Declaration): New routine.
(Is_Ghost_Entity): Removed.
(Is_Ghost_Statement_Or_Pragma):
Removed.
(Is_Subject_To_Ghost): Removed.
(Set_Is_Ghost_Entity):
Removed.
(Within_Ghost_Scope): Removed.
* sem_util.adb (Check_Ghost_Completion): Removed.
(Check_Ghost_Derivation): Removed.
(Is_Declaration): New routine.
(Is_Ghost_Entity): Removed.
(Is_Ghost_Statement_Or_Pragma): Removed.
(Is_Subject_To_Ghost): Removed.
(Set_Is_Ghost_Entity): Removed.
(Within_Ghost_Scope): Removed.
* sinfo.ads Add a section on Ghost mode.
* treepr.adb (Print_Header_Flag): New routine.
(Print_Node_Header): Factor out code. Output flag
Is_Ignored_Ghost_Node.
* gcc-interface/Make-lang.in: Add dependency for unit Ghost.
From-SVN: r219280
Diffstat (limited to 'gcc/ada/ghost.ads')
-rw-r--r-- | gcc/ada/ghost.ads | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/gcc/ada/ghost.ads b/gcc/ada/ghost.ads new file mode 100644 index 0000000..436e84f --- /dev/null +++ b/gcc/ada/ghost.ads @@ -0,0 +1,115 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- G H O S T -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2014-2015, Free Software Foundation, Inc. -- +-- -- +-- 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- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- +-- for more details. You should have received a copy of the GNU General -- +-- Public License distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This package contains routines that deal with the static and runtime +-- semantics of Ghost entities. + +with Types; use Types; + +package Ghost is + + procedure Add_Ignored_Ghost_Unit (Unit : Node_Id); + -- Add a single ignored Ghost compilation unit to the internal table for + -- post processing. + + procedure Check_Ghost_Completion + (Partial_View : Entity_Id; + Full_View : Entity_Id); + -- Verify that the Ghost policy of a full view or a completion is the same + -- as the Ghost policy of the partial view. Emit an error if this is not + -- the case. + + procedure Check_Ghost_Context (Ghost_Id : Entity_Id; Ghost_Ref : Node_Id); + -- Determine whether node Ghost_Ref appears within a Ghost-friendly context + -- where Ghost entity Ghost_Id can safely reside. + + procedure Check_Ghost_Derivation (Typ : Entity_Id); + -- Verify that the parent type and all progenitors of derived type or type + -- extension Typ are Ghost. If this is not the case, issue an error. + + function Implements_Ghost_Interface (Typ : Entity_Id) return Boolean; + -- Determine whether type Typ implements at least one Ghost interface + + procedure Initialize; + -- Initialize internal tables + + function Is_Ghost_Entity (Id : Entity_Id) return Boolean; + -- Determine whether entity Id is Ghost. To qualify as such, the entity + -- must be subject to pragma Ghost. + + function Is_Subject_To_Ghost (N : Node_Id) return Boolean; + -- Determine whether declarative node N is subject to aspect or pragma + -- Ghost. Use this routine in cases where [source] pragma Ghost has not + -- been analyzed yet, but the context needs to establish the "ghostness" + -- of N. + + procedure Lock; + -- Lock internal tables before calling backend + + procedure Remove_Ignored_Ghost_Code; + -- Remove all code marked as ignored Ghost from the trees of all qualifying + -- units. + -- + -- WARNING: this is a separate front end pass, care should be taken to keep + -- it optimized. + + procedure Set_Ghost_Mode (N : Node_Id; Prev_Id : Entity_Id := Empty); + -- Set the value of global variable Ghost_Mode depending on the following + -- scenarios: + -- + -- If N is a declaration, determine whether N is subject to pragma Ghost. + -- If this is the case, the Ghost_Mode is set based on the current Ghost + -- policy in effect. Special cases: + -- + -- N is the completion of a deferred constant, Prev_Id denotes the + -- entity of the partial declaration. + -- + -- N is the full view of a private type, Prev_Id denotes the entity + -- of the partial declaration. + -- + -- If N is an assignment statement or a procedure call, determine whether + -- the name of N denotes a reference to a Ghost entity. If this is the + -- case, the Global_Mode is set based on the mode of the name. + -- + -- If N denotes a package or a subprogram body, determine whether the + -- corresponding spec Prev_Id is a Ghost entity or the body is subject + -- to pragma Ghost. If this is the case, the Global_Mode is set based on + -- the current Ghost policy in effect. + -- + -- WARNING: the caller must save and restore the value of Ghost_Mode in a + -- a stack-like fasion as this routine may override the existing value. + + procedure Set_Ghost_Mode_For_Freeze (Id : Entity_Id; N : Node_Id); + -- Set the value of global variable Ghost_Mode depending on the mode of + -- entity Id. N denotes the context of the freeze. + -- + -- WARNING: the caller must save and restore the value of Ghost_Mode in a + -- a stack-like fasion as this routine may override the existing value. + + procedure Set_Is_Ghost_Entity (Id : Entity_Id); + -- Set the relevant ghost attribute of entity Id depending on the current + -- Ghost assertion policy in effect. + +end Ghost; |