aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/contracts.ads
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-10-23 15:04:01 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2015-10-23 15:04:01 +0200
commit879ac954ef76a1af1888abfaa44257f6f728372b (patch)
treedff0f664288fdfea6014177ce744d3e81f47c203 /gcc/ada/contracts.ads
parent9733088f6ab15a857474e6b66f4757e9710f1a37 (diff)
downloadgcc-879ac954ef76a1af1888abfaa44257f6f728372b.zip
gcc-879ac954ef76a1af1888abfaa44257f6f728372b.tar.gz
gcc-879ac954ef76a1af1888abfaa44257f6f728372b.tar.bz2
[multiple changes]
2015-10-23 Hristian Kirtchev <kirtchev@adacore.com> * contracts.ads, contracts.adb: New unit. * exp_ch6.adb Add with and use clauses for Contracts. (Expand_Subprogram_Contract): Moved to Contracts. * exp_ch6.ads (Expand_Subprogram_Contract): Moved to Contracts. * sem_ch3.adb Add with and use clauses for Contracts. (Analyze_Object_Contract): Moved to Contracts. (Analyze_Declarations): Remove local variable Pack_Decl. Do not capture global references in contracts. Check the hidden states of a package body. * sem_ch6.adb Add with and use clauses in Contracts. (Analyze_Generic_Subprogram_Body): Do not capture global references in contracts. (Analyze_Subprogram_Body_Contract): Moved to Contracts. (Analyze_Subprogram_Body_Helper): Freeze the contract of the nearest enclosing package body. Always analyze the subprogram body contract. Do not expand the subprogram body contract. (Analyze_Subprogram_Contract): Moved to Contracts. * sem_ch6.ads (Analyze_Subprogram_Body_Contract): Moved to Contracts. (Analyze_Subprogram_Contract): Moved to Contracts. * sem_ch7.adb Add with and use clauses for Contracts. (Analyze_Package_Body_Contract): Moved to Contracts. (Analyze_Package_Body_Helper): Freeze the contract of the nearest enclosing package body. (Analyze_Package_Contract): Moved to Contracts. * sem_ch7.ads (Analyze_Package_Body_Contract): Moved to Contracts. (Analyze_Package_Contract): Moved to Contracts. * sem_ch10.adb Add with and use clauses for Contracts. (Analyze_Compilation_Unit): Do not capture global references in contracts. (Analyze_Subprogram_Body_Stub_Contract): Moved to Contracts. * sem_ch10.ads (Analyze_Subprogram_Body_Stub_Contract): Moved to Contracts. * sem_ch12.adb Add with and use clauses for Contracts. (Analyze_Subprogram_Instantiation): Update the call to Instantiate_Subprogram_Contract. (Instantiate_Package_Body): Do not copy the entity of the spec when creating an entity for the body. Construct a brand new defining identifier for the body and inherit the Comes_From_Source flag from the spec. (Instantiate_Subprogram_Body): Remove Anon_Id to Act_Decl_Id and update all occurrences. Construct a brand new defining identifier for the body and inherit the Comes_From_Source flag from the spec. (Instantiate_Subprogram_Contract): Moved to Contracts. (Save_Global_References_In_Aspects): Moved to the spec of Sem_Ch12. (Save_Global_References_In_Contract): Moved to Contracts. * sem_ch12.ads (Save_Global_References_In_Aspects): Moved from the body of Sem_Ch12. (Save_Global_References_In_Contract): Moved to Contracts. * sem_prag.adb Add with and use clauses for Contracts. (Add_Item): Removed. All references to this routine have been replaced with calls to Append_New_Elmt. (Analyze_Constituent): Add special diagnostics for errors caused by freezing of contracts. (Analyze_Refined_State_In_Decl_Part): Add formal parameter Freeze_Id. Add new global variable Freeze_Posted. (Collect_Body_States): Removed. (Report_Unused_States): Removed. * sem_prag.ads (Analyze_Defined_State_In_Decl_Part): Add formal parameter Freeze_Id and update comment on usage. * sem_util.adb Remove with and use clauses for Sem_Ch12. (Add_Contract_Item): Moved to Contracts. (Check_Unused_Body_States): New routine. (Collect_Body_States): New routine. (Create_Generic_Contract): Moved to Contracts. (Inherit_Subprogram_Contract): Moved to Contracts. (Report_Unused_Body_States): New routine. * sem_util.ads (Add_Contract_Item): Moved to Contracts. (Check_Unused_Body_States): New routine. (Collect_Body_States): New routine. (Create_Generic_Contract): Moved to Contracts. (Inherit_Subprogram_Contract): Moved to Contracts. (Report_Unused_Body_States): New routine. * sinfo.adb (Is_Expanded_Contract): New routine. (Set_Is_Expanded_Contract): New routine. * sinfo.ads New attribute Is_Expanded_Contract along with placement in nodes. (Is_Expanded_Contract): New routine along with pragma Inline. (Set_Is_Expanded_Contract): New routine along with pragma Inline. * gcc-interface/Make-lang.in: Add entry for contracts.o 2015-10-23 Bob Duff <duff@adacore.com> * bindgen.adb, init.c, opt.ads, switch-b.adb: Implement new -Ea and -Es switches. * switch-b.ads: Minor comment fix. * bindusg.adb: Document new -Ea and -Es switches. * s-exctra.ads: Use -Es instead of -E. From-SVN: r229253
Diffstat (limited to 'gcc/ada/contracts.ads')
-rw-r--r--gcc/ada/contracts.ads156
1 files changed, 156 insertions, 0 deletions
diff --git a/gcc/ada/contracts.ads b/gcc/ada/contracts.ads
new file mode 100644
index 0000000..beeed57
--- /dev/null
+++ b/gcc/ada/contracts.ads
@@ -0,0 +1,156 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT COMPILER COMPONENTS --
+-- --
+-- C O N T R A C T S --
+-- --
+-- S p e c --
+-- --
+-- Copyright (C) 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 perform analysis and expansion of
+-- various contracts.
+
+with Types; use Types;
+
+package Contracts is
+
+ procedure Add_Contract_Item (Prag : Node_Id; Id : Entity_Id);
+ -- Add pragma Prag to the contract of a constant, entry, package [body],
+ -- subprogram [body] or variable denoted by Id. The following are valid
+ -- pragmas:
+ -- Abstract_State
+ -- Async_Readers
+ -- Async_Writers
+ -- Constant_After_Elaboration
+ -- Contract_Cases
+ -- Depends
+ -- Effective_Reads
+ -- Effective_Writes
+ -- Extensions_Visible
+ -- Global
+ -- Initial_Condition
+ -- Initializes
+ -- Part_Of
+ -- Postcondition
+ -- Precondition
+ -- Refined_Depends
+ -- Refined_Global
+ -- Refined_Post
+ -- Refined_States
+ -- Test_Case
+ -- Volatile_Function
+
+ procedure Analyze_Enclosing_Package_Body_Contract (Body_Decl : Node_Id);
+ -- Analyze the contract of the nearest package body (if any) which encloses
+ -- package or subprogram body Body_Decl.
+
+ procedure Analyze_Object_Contract (Obj_Id : Entity_Id);
+ -- Analyze all delayed pragmas chained on the contract of object Obj_Id as
+ -- if they appeared at the end of the declarative region. The pragmas to be
+ -- considered are:
+ -- Async_Readers
+ -- Async_Writers
+ -- Effective_Reads
+ -- Effective_Writes
+ -- Part_Of
+
+ procedure Analyze_Package_Body_Contract
+ (Body_Id : Entity_Id;
+ Freeze_Id : Entity_Id := Empty);
+ -- Analyze all delayed aspects chained on the contract of package body
+ -- Body_Id as if they appeared at the end of a declarative region. The
+ -- aspects that are considered are:
+ -- Refined_State
+ --
+ -- Freeze_Id is the entity of a [generic] package body or a [generic]
+ -- subprogram body which "feezes" the contract of Body_Id.
+
+ procedure Analyze_Package_Contract (Pack_Id : Entity_Id);
+ -- Analyze all delayed aspects chained on the contract of package Pack_Id
+ -- as if they appeared at the end of a declarative region. The aspects
+ -- that are considered are:
+ -- Initial_Condition
+ -- Initializes
+ -- Part_Of
+
+ procedure Analyze_Subprogram_Body_Contract (Body_Id : Entity_Id);
+ -- Analyze all delayed aspects chained on the contract of subprogram body
+ -- Body_Id as if they appeared at the end of a declarative region. Aspects
+ -- in question are:
+ -- Contract_Cases (stand alone body)
+ -- Depends (stand alone body)
+ -- Global (stand alone body)
+ -- Postcondition (stand alone body)
+ -- Precondition (stand alone body)
+ -- Refined_Depends
+ -- Refined_Global
+ -- Refined_Post
+ -- Test_Case (stand alone body)
+
+ procedure Analyze_Subprogram_Contract (Subp_Id : Entity_Id);
+ -- Analyze all delayed aspects chained on the contract of subprogram
+ -- Subp_Id as if they appeared at the end of a declarative region. The
+ -- aspects in question are:
+ -- Contract_Cases
+ -- Depends
+ -- Global
+ -- Postcondition
+ -- Precondition
+ -- Test_Case
+
+ procedure Analyze_Subprogram_Body_Stub_Contract (Stub_Id : Entity_Id);
+ -- Analyze all delayed aspects chained on the contract of a subprogram body
+ -- stub Stub_Id as if they appeared at the end of a declarative region. The
+ -- aspects in question are:
+ -- Contract_Cases
+ -- Depends
+ -- Global
+ -- Postcondition
+ -- Precondition
+ -- Refined_Depends
+ -- Refined_Global
+ -- Refined_Post
+ -- Test_Case
+
+ procedure Create_Generic_Contract (Unit : Node_Id);
+ -- Create a contract node for a generic package, generic subprogram or a
+ -- generic body denoted by Unit by collecting all source contract-related
+ -- pragmas in the contract of the unit.
+
+ procedure Inherit_Subprogram_Contract
+ (Subp : Entity_Id;
+ From_Subp : Entity_Id);
+ -- Inherit relevant contract items from source subprogram From_Subp. Subp
+ -- denotes the destination subprogram. The inherited items are:
+ -- Extensions_Visible
+ -- ??? it would be nice if this routine handles Pre'Class and Post'Class
+
+ procedure Instantiate_Subprogram_Contract (Templ : Node_Id; L : List_Id);
+ -- Instantiate all source pragmas found in the contract of the generic
+ -- subprogram declaration template denoted by Templ. The instantiated
+ -- pragmas are added to list L.
+
+ procedure Save_Global_References_In_Contract
+ (Templ : Node_Id;
+ Gen_Id : Entity_Id);
+ -- Save all global references found within the aspect specifications and
+ -- the contract-related source pragmas assocated with generic template
+ -- Templ. Gen_Id denotes the entity of the analyzed generic copy.
+
+end Contracts;