Commit 879ac954 by Arnaud Charlet

[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
parent 9733088f
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.
2015-10-23 Tristan Gingold <gingold@adacore.com> 2015-10-23 Tristan Gingold <gingold@adacore.com>
* gcc-interface/utils2.c (build_call_alloc_dealloc): Check no implicit * gcc-interface/utils2.c (build_call_alloc_dealloc): Check no implicit
......
...@@ -166,6 +166,7 @@ package body Bindgen is ...@@ -166,6 +166,7 @@ package body Bindgen is
-- Num_Interrupt_States : Integer; -- Num_Interrupt_States : Integer;
-- Unreserve_All_Interrupts : Integer; -- Unreserve_All_Interrupts : Integer;
-- Exception_Tracebacks : Integer; -- Exception_Tracebacks : Integer;
-- Exception_Tracebacks_Symbolic : Integer;
-- Detect_Blocking : Integer; -- Detect_Blocking : Integer;
-- Default_Stack_Size : Integer; -- Default_Stack_Size : Integer;
-- Leap_Seconds_Support : Integer; -- Leap_Seconds_Support : Integer;
...@@ -235,10 +236,13 @@ package body Bindgen is ...@@ -235,10 +236,13 @@ package body Bindgen is
-- Unreserve_All_Interrupts is set to one if at least one unit in the -- Unreserve_All_Interrupts is set to one if at least one unit in the
-- partition had a pragma Unreserve_All_Interrupts, and zero otherwise. -- partition had a pragma Unreserve_All_Interrupts, and zero otherwise.
-- Exception_Tracebacks is set to one if the -E parameter was present -- Exception_Tracebacks is set to one if the -Ea or -E parameter was
-- in the bind and to zero otherwise. Note that on some targets exception -- present in the bind and to zero otherwise. Note that on some targets
-- tracebacks are provided by default, so a value of zero for this -- exception tracebacks are provided by default, so a value of zero for
-- parameter does not necessarily mean no trace backs are available. -- this parameter does not necessarily mean no trace backs are available.
-- Exception_Tracebacks_Symbolic is set to one if the -Es parameter was
-- present in the bind and to zero otherwise.
-- Detect_Blocking indicates whether pragma Detect_Blocking is active or -- Detect_Blocking indicates whether pragma Detect_Blocking is active or
-- not. A value of zero indicates that the pragma is not present, while a -- not. A value of zero indicates that the pragma is not present, while a
...@@ -607,10 +611,16 @@ package body Bindgen is ...@@ -607,10 +611,16 @@ package body Bindgen is
WBI (" pragma Import (C, Unreserve_All_Interrupts, " & WBI (" pragma Import (C, Unreserve_All_Interrupts, " &
"""__gl_unreserve_all_interrupts"");"); """__gl_unreserve_all_interrupts"");");
if Exception_Tracebacks then if Exception_Tracebacks or Exception_Tracebacks_Symbolic then
WBI (" Exception_Tracebacks : Integer;"); WBI (" Exception_Tracebacks : Integer;");
WBI (" pragma Import (C, Exception_Tracebacks, " & WBI (" pragma Import (C, Exception_Tracebacks, " &
"""__gl_exception_tracebacks"");"); """__gl_exception_tracebacks"");");
if Exception_Tracebacks_Symbolic then
WBI (" Exception_Tracebacks_Symbolic : Integer;");
WBI (" pragma Import (C, Exception_Tracebacks_Symbolic, " &
"""__gl_exception_tracebacks_symbolic"");");
end if;
end if; end if;
WBI (" Detect_Blocking : Integer;"); WBI (" Detect_Blocking : Integer;");
...@@ -795,8 +805,12 @@ package body Bindgen is ...@@ -795,8 +805,12 @@ package body Bindgen is
Set_Char (';'); Set_Char (';');
Write_Statement_Buffer; Write_Statement_Buffer;
if Exception_Tracebacks then if Exception_Tracebacks or Exception_Tracebacks_Symbolic then
WBI (" Exception_Tracebacks := 1;"); WBI (" Exception_Tracebacks := 1;");
if Exception_Tracebacks_Symbolic then
WBI (" Exception_Tracebacks_Symbolic := 1;");
end if;
end if; end if;
Set_String (" Detect_Blocking := "); Set_String (" Detect_Blocking := ");
......
...@@ -108,7 +108,10 @@ package body Bindusg is ...@@ -108,7 +108,10 @@ package body Bindusg is
-- Line for -E switch -- Line for -E switch
Write_Line (" -E Store tracebacks in exception occurrences"); Write_Line (" -Ea Store tracebacks in exception occurrences");
Write_Line (" -Es Store tracebacks in exception occurrences,");
Write_Line (" and enable symbolic tracebacks");
Write_Line (" -E Same as -Ea");
-- The -f switch is voluntarily omitted, because it is obsolete -- The -f switch is voluntarily omitted, because it is obsolete
......
------------------------------------------------------------------------------
-- --
-- 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;
...@@ -41,12 +41,6 @@ package Exp_Ch6 is ...@@ -41,12 +41,6 @@ package Exp_Ch6 is
-- This procedure contains common processing for Expand_N_Function_Call, -- This procedure contains common processing for Expand_N_Function_Call,
-- Expand_N_Procedure_Statement, and Expand_N_Entry_Call. -- Expand_N_Procedure_Statement, and Expand_N_Entry_Call.
procedure Expand_Subprogram_Contract (N : Node_Id);
-- Expand the contracts of a subprogram body and its correspoding spec (if
-- any). This routine processes all [refined] pre- and postconditions as
-- well as Contract_Cases, invariants and predicates. N denotes the body of
-- the subprogram.
procedure Freeze_Subprogram (N : Node_Id); procedure Freeze_Subprogram (N : Node_Id);
-- generate the appropriate expansions related to Subprogram freeze -- generate the appropriate expansions related to Subprogram freeze
-- nodes (e.g. the filling of the corresponding Dispatch Table for -- nodes (e.g. the filling of the corresponding Dispatch Table for
......
...@@ -243,6 +243,7 @@ GNAT_ADA_OBJS = \ ...@@ -243,6 +243,7 @@ GNAT_ADA_OBJS = \
ada/casing.o \ ada/casing.o \
ada/checks.o \ ada/checks.o \
ada/comperr.o \ ada/comperr.o \
ada/contracts.o \
ada/csets.o \ ada/csets.o \
ada/cstand.o \ ada/cstand.o \
ada/debug.o \ ada/debug.o \
......
...@@ -110,6 +110,7 @@ char *__gl_interrupt_states = 0; ...@@ -110,6 +110,7 @@ char *__gl_interrupt_states = 0;
int __gl_num_interrupt_states = 0; int __gl_num_interrupt_states = 0;
int __gl_unreserve_all_interrupts = 0; int __gl_unreserve_all_interrupts = 0;
int __gl_exception_tracebacks = 0; int __gl_exception_tracebacks = 0;
int __gl_exception_tracebacks_symbolic = 0;
int __gl_detect_blocking = 0; int __gl_detect_blocking = 0;
int __gl_default_stack_size = -1; int __gl_default_stack_size = -1;
int __gl_leap_seconds_support = 0; int __gl_leap_seconds_support = 0;
......
...@@ -595,7 +595,12 @@ package Opt is ...@@ -595,7 +595,12 @@ package Opt is
Exception_Tracebacks : Boolean := False; Exception_Tracebacks : Boolean := False;
-- GNATBIND -- GNATBIND
-- Set to True to store tracebacks in exception occurrences (-E) -- Set to True to store tracebacks in exception occurrences (-Ea or -E)
Exception_Tracebacks_Symbolic : Boolean := False;
-- GNATBIND
-- Set to True to store tracebacks in exception occurrences and enable
-- symbolic tracebacks (-Es).
Extensions_Allowed : Boolean := False; Extensions_Allowed : Boolean := False;
-- GNAT -- GNAT
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
-- may return any string output in association with a provided call chain. -- may return any string output in association with a provided call chain.
-- The decorator replaces the default backtrace mentioned above. -- The decorator replaces the default backtrace mentioned above.
-- On systems that use DWARF debugging output, then if the "-g" compiler
-- switch and the "-Es" binder switch are used, the decorator is automatically
-- set to Symbolic_Traceback.
with System.Traceback_Entries; with System.Traceback_Entries;
package System.Exception_Traces is package System.Exception_Traces is
...@@ -89,12 +93,15 @@ package System.Exception_Traces is ...@@ -89,12 +93,15 @@ package System.Exception_Traces is
-- output for a call chain provided by way of a tracebacks array. -- output for a call chain provided by way of a tracebacks array.
procedure Set_Trace_Decorator (Decorator : Traceback_Decorator); procedure Set_Trace_Decorator (Decorator : Traceback_Decorator);
-- Set the decorator to be used for future automatic outputs. Restore -- Set the decorator to be used for future automatic outputs. Restore the
-- the default behavior (output of raw addresses) if the provided -- default behavior if the provided access value is null.
-- access value is null.
-- --
-- Note: System.Traceback.Symbolic.Symbolic_Traceback may be used as the -- Note: System.Traceback.Symbolic.Symbolic_Traceback may be used as the
-- Decorator, to get a symbolic traceback. This will cause a significant -- Decorator, to get a symbolic traceback. This will cause a significant
-- cpu and memory overhead. -- cpu and memory overhead on some platforms.
--
-- Note: The Decorator is called when constructing the
-- Exception_Information; that needs to be taken into account
-- if the Decorator has any side effects.
end System.Exception_Traces; end System.Exception_Traces;
...@@ -23,50 +23,50 @@ ...@@ -23,50 +23,50 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects; with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Debug; use Debug; with Contracts; use Contracts;
with Einfo; use Einfo; with Debug; use Debug;
with Errout; use Errout; with Einfo; use Einfo;
with Exp_Util; use Exp_Util; with Errout; use Errout;
with Elists; use Elists; with Exp_Util; use Exp_Util;
with Fname; use Fname; with Elists; use Elists;
with Fname.UF; use Fname.UF; with Fname; use Fname;
with Freeze; use Freeze; with Fname.UF; use Fname.UF;
with Impunit; use Impunit; with Freeze; use Freeze;
with Inline; use Inline; with Impunit; use Impunit;
with Lib; use Lib; with Inline; use Inline;
with Lib.Load; use Lib.Load; with Lib; use Lib;
with Lib.Xref; use Lib.Xref; with Lib.Load; use Lib.Load;
with Namet; use Namet; with Lib.Xref; use Lib.Xref;
with Nlists; use Nlists; with Namet; use Namet;
with Nmake; use Nmake; with Nlists; use Nlists;
with Opt; use Opt; with Nmake; use Nmake;
with Output; use Output; with Opt; use Opt;
with Par_SCO; use Par_SCO; with Output; use Output;
with Restrict; use Restrict; with Par_SCO; use Par_SCO;
with Rident; use Rident; with Restrict; use Restrict;
with Rtsfind; use Rtsfind; with Rident; use Rident;
with Sem; use Sem; with Rtsfind; use Rtsfind;
with Sem_Aux; use Sem_Aux; with Sem; use Sem;
with Sem_Ch3; use Sem_Ch3; with Sem_Aux; use Sem_Aux;
with Sem_Ch6; use Sem_Ch6; with Sem_Ch3; use Sem_Ch3;
with Sem_Ch7; use Sem_Ch7; with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch7; use Sem_Ch7;
with Sem_Ch12; use Sem_Ch12; with Sem_Ch8; use Sem_Ch8;
with Sem_Dist; use Sem_Dist; with Sem_Dist; use Sem_Dist;
with Sem_Prag; use Sem_Prag; with Sem_Prag; use Sem_Prag;
with Sem_Util; use Sem_Util; with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn; with Sem_Warn; use Sem_Warn;
with Stand; use Stand; with Stand; use Stand;
with Sinfo; use Sinfo; with Sinfo; use Sinfo;
with Sinfo.CN; use Sinfo.CN; with Sinfo.CN; use Sinfo.CN;
with Sinput; use Sinput; with Sinput; use Sinput;
with Snames; use Snames; with Snames; use Snames;
with Style; use Style; with Style; use Style;
with Stylesw; use Stylesw; with Stylesw; use Stylesw;
with Tbuild; use Tbuild; with Tbuild; use Tbuild;
with Uname; use Uname; with Uname; use Uname;
package body Sem_Ch10 is package body Sem_Ch10 is
...@@ -940,15 +940,6 @@ package body Sem_Ch10 is ...@@ -940,15 +940,6 @@ package body Sem_Ch10 is
N_Subprogram_Declaration) N_Subprogram_Declaration)
then then
Analyze_Subprogram_Contract (Defining_Entity (Unit_Node)); Analyze_Subprogram_Contract (Defining_Entity (Unit_Node));
-- Capture all global references in a generic subprogram that acts as
-- a compilation unit now that the contract has been analyzed.
if Is_Generic_Declaration_Or_Body (Unit_Node) then
Save_Global_References_In_Contract
(Templ => Original_Node (Unit_Node),
Gen_Id => Defining_Entity (Unit_Node));
end if;
end if; end if;
-- Generate distribution stubs if requested and no error -- Generate distribution stubs if requested and no error
...@@ -2006,39 +1997,6 @@ package body Sem_Ch10 is ...@@ -2006,39 +1997,6 @@ package body Sem_Ch10 is
Restore_Opt_Config_Switches (Opts); Restore_Opt_Config_Switches (Opts);
end Analyze_Subprogram_Body_Stub; end Analyze_Subprogram_Body_Stub;
-------------------------------------------
-- Analyze_Subprogram_Body_Stub_Contract --
-------------------------------------------
procedure Analyze_Subprogram_Body_Stub_Contract (Stub_Id : Entity_Id) is
Stub_Decl : constant Node_Id := Parent (Parent (Stub_Id));
Spec_Id : constant Entity_Id := Corresponding_Spec_Of_Stub (Stub_Decl);
begin
-- A subprogram body stub may act as its own spec or as the completion
-- of a previous declaration. Depending on the context, the contract of
-- the stub may contain two sets of pragmas.
-- The stub is a completion, the applicable pragmas are:
-- Refined_Depends
-- Refined_Global
if Present (Spec_Id) then
Analyze_Subprogram_Body_Contract (Stub_Id);
-- The stub acts as its own spec, the applicable pragmas are:
-- Contract_Cases
-- Depends
-- Global
-- Postcondition
-- Precondition
-- Test_Case
else
Analyze_Subprogram_Contract (Stub_Id);
end if;
end Analyze_Subprogram_Body_Stub_Contract;
--------------------- ---------------------
-- Analyze_Subunit -- -- Analyze_Subunit --
--------------------- ---------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2015, 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- --
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Types; use Types; with Types; use Types;
package Sem_Ch10 is package Sem_Ch10 is
procedure Analyze_Compilation_Unit (N : Node_Id); procedure Analyze_Compilation_Unit (N : Node_Id);
procedure Analyze_With_Clause (N : Node_Id); procedure Analyze_With_Clause (N : Node_Id);
...@@ -33,19 +34,6 @@ package Sem_Ch10 is ...@@ -33,19 +34,6 @@ package Sem_Ch10 is
procedure Analyze_Protected_Body_Stub (N : Node_Id); procedure Analyze_Protected_Body_Stub (N : Node_Id);
procedure Analyze_Subunit (N : Node_Id); procedure Analyze_Subunit (N : Node_Id);
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
-- Test_Case
procedure Install_Context (N : Node_Id); procedure Install_Context (N : Node_Id);
-- Installs the entities from the context clause of the given compilation -- Installs the entities from the context clause of the given compilation
-- unit into the visibility chains. This is done before analyzing a unit. -- unit into the visibility chains. This is done before analyzing a unit.
......
...@@ -152,12 +152,9 @@ package Sem_Ch12 is ...@@ -152,12 +152,9 @@ package Sem_Ch12 is
-- restored in stack-like fashion. Front-end inlining also uses these -- restored in stack-like fashion. Front-end inlining also uses these
-- structures for the management of private/full views. -- structures for the management of private/full views.
procedure Save_Global_References_In_Contract procedure Save_Global_References_In_Aspects (N : Node_Id);
(Templ : Node_Id; -- Save all global references found within the expressions of all aspects
Gen_Id : Entity_Id); -- that appear on node N.
-- 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.
procedure Set_Copied_Sloc_For_Inlined_Body (N : Node_Id; E : Entity_Id); procedure Set_Copied_Sloc_For_Inlined_Body (N : Node_Id; E : Entity_Id);
-- This procedure is used when a subprogram body is inlined. This process -- This procedure is used when a subprogram body is inlined. This process
......
...@@ -45,31 +45,6 @@ package Sem_Ch6 is ...@@ -45,31 +45,6 @@ package Sem_Ch6 is
procedure Analyze_Subprogram_Declaration (N : Node_Id); procedure Analyze_Subprogram_Declaration (N : Node_Id);
procedure Analyze_Subprogram_Body (N : Node_Id); procedure Analyze_Subprogram_Body (N : Node_Id);
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
function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id; function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id;
-- Analyze subprogram specification in both subprogram declarations -- Analyze subprogram specification in both subprogram declarations
-- and body declarations. Returns the defining entity for the -- and body declarations. Returns the defining entity for the
......
...@@ -28,44 +28,45 @@ ...@@ -28,44 +28,45 @@
-- handling of private and full declarations, and the construction of dispatch -- handling of private and full declarations, and the construction of dispatch
-- tables for tagged types. -- tables for tagged types.
with Aspects; use Aspects; with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Debug; use Debug; with Contracts; use Contracts;
with Einfo; use Einfo; with Debug; use Debug;
with Elists; use Elists; with Einfo; use Einfo;
with Errout; use Errout; with Elists; use Elists;
with Exp_Disp; use Exp_Disp; with Errout; use Errout;
with Exp_Dist; use Exp_Dist; with Exp_Disp; use Exp_Disp;
with Exp_Dbug; use Exp_Dbug; with Exp_Dist; use Exp_Dist;
with Ghost; use Ghost; with Exp_Dbug; use Exp_Dbug;
with Lib; use Lib; with Ghost; use Ghost;
with Lib.Xref; use Lib.Xref; with Lib; use Lib;
with Namet; use Namet; with Lib.Xref; use Lib.Xref;
with Nmake; use Nmake; with Namet; use Namet;
with Nlists; use Nlists; with Nmake; use Nmake;
with Opt; use Opt; with Nlists; use Nlists;
with Output; use Output; with Opt; use Opt;
with Restrict; use Restrict; with Output; use Output;
with Sem; use Sem; with Restrict; use Restrict;
with Sem_Aux; use Sem_Aux; with Sem; use Sem;
with Sem_Cat; use Sem_Cat; with Sem_Aux; use Sem_Aux;
with Sem_Ch3; use Sem_Ch3; with Sem_Cat; use Sem_Cat;
with Sem_Ch6; use Sem_Ch6; with Sem_Ch3; use Sem_Ch3;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch6; use Sem_Ch6;
with Sem_Ch10; use Sem_Ch10; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch12; use Sem_Ch12; with Sem_Ch10; use Sem_Ch10;
with Sem_Ch13; use Sem_Ch13; with Sem_Ch12; use Sem_Ch12;
with Sem_Disp; use Sem_Disp; with Sem_Ch13; use Sem_Ch13;
with Sem_Eval; use Sem_Eval; with Sem_Disp; use Sem_Disp;
with Sem_Prag; use Sem_Prag; with Sem_Eval; use Sem_Eval;
with Sem_Util; use Sem_Util; with Sem_Prag; use Sem_Prag;
with Sem_Warn; use Sem_Warn; with Sem_Util; use Sem_Util;
with Snames; use Snames; with Sem_Warn; use Sem_Warn;
with Stand; use Stand; with Snames; use Snames;
with Sinfo; use Sinfo; with Stand; use Stand;
with Sinput; use Sinput; with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Style; with Style;
with Uintp; use Uintp; with Uintp; use Uintp;
package body Sem_Ch7 is package body Sem_Ch7 is
...@@ -182,47 +183,6 @@ package body Sem_Ch7 is ...@@ -182,47 +183,6 @@ package body Sem_Ch7 is
end if; end if;
end Analyze_Package_Body; end Analyze_Package_Body;
-----------------------------------
-- Analyze_Package_Body_Contract --
-----------------------------------
procedure Analyze_Package_Body_Contract (Body_Id : Entity_Id) is
Spec_Id : constant Entity_Id := Spec_Entity (Body_Id);
Mode : SPARK_Mode_Type;
Ref_State : Node_Id;
begin
-- Due to the timing of contract analysis, delayed pragmas may be
-- subject to the wrong SPARK_Mode, usually that of the enclosing
-- context. To remedy this, restore the original SPARK_Mode of the
-- related package body.
Save_SPARK_Mode_And_Set (Body_Id, Mode);
Ref_State := Get_Pragma (Body_Id, Pragma_Refined_State);
-- The analysis of pragma Refined_State detects whether the spec has
-- abstract states available for refinement.
if Present (Ref_State) then
Analyze_Refined_State_In_Decl_Part (Ref_State);
-- State refinement is required when the package declaration defines at
-- least one abstract state. Null states are not considered. Refinement
-- is not envorced when SPARK checks are turned off.
elsif SPARK_Mode /= Off
and then Requires_State_Refinement (Spec_Id, Body_Id)
then
Error_Msg_N ("package & requires state refinement", Spec_Id);
end if;
-- Restore the SPARK_Mode of the enclosing context after all delayed
-- pragmas have been analyzed.
Restore_SPARK_Mode (Mode);
end Analyze_Package_Body_Contract;
--------------------------------- ---------------------------------
-- Analyze_Package_Body_Helper -- -- Analyze_Package_Body_Helper --
--------------------------------- ---------------------------------
...@@ -582,6 +542,30 @@ package body Sem_Ch7 is ...@@ -582,6 +542,30 @@ package body Sem_Ch7 is
-- Start of processing for Analyze_Package_Body_Helper -- Start of processing for Analyze_Package_Body_Helper
begin begin
-- A [generic] package body "freezes" the contract of the nearest
-- enclosing package body:
-- package body Nearest_Enclosing_Package
-- with Refined_State => (State => Constit)
-- is
-- Constit : ...;
-- package body Freezes_Enclosing_Package_Body
-- with Refined_State => (State_2 => Constit_2)
-- is
-- Constit_2 : ...;
-- procedure Proc
-- with Refined_Depends => (Input => (Constit, Constit_2)) ...
-- This ensures that any annotations referenced by the contract of a
-- [generic] subprogram body declared within the current package body
-- are available. This form of "freezing" is decoupled from the usual
-- Freeze_xxx mechanism because it must also work in the context of
-- generics where normal freezing is disabled.
Analyze_Enclosing_Package_Body_Contract (N);
-- Find corresponding package specification, and establish the current -- Find corresponding package specification, and establish the current
-- scope. The visible defining entity for the package is the defining -- scope. The visible defining entity for the package is the defining
-- occurrence in the spec. On exit from the package body, all body -- occurrence in the spec. On exit from the package body, all body
...@@ -944,74 +928,6 @@ package body Sem_Ch7 is ...@@ -944,74 +928,6 @@ package body Sem_Ch7 is
Ghost_Mode := Save_Ghost_Mode; Ghost_Mode := Save_Ghost_Mode;
end Analyze_Package_Body_Helper; end Analyze_Package_Body_Helper;
------------------------------
-- Analyze_Package_Contract --
------------------------------
procedure Analyze_Package_Contract (Pack_Id : Entity_Id) is
Items : constant Node_Id := Contract (Pack_Id);
Init : Node_Id := Empty;
Init_Cond : Node_Id := Empty;
Mode : SPARK_Mode_Type;
Prag : Node_Id;
Prag_Nam : Name_Id;
begin
-- Due to the timing of contract analysis, delayed pragmas may be
-- subject to the wrong SPARK_Mode, usually that of the enclosing
-- context. To remedy this, restore the original SPARK_Mode of the
-- related package.
Save_SPARK_Mode_And_Set (Pack_Id, Mode);
if Present (Items) then
-- Locate and store pragmas Initial_Condition and Initializes since
-- their order of analysis matters.
Prag := Classifications (Items);
while Present (Prag) loop
Prag_Nam := Pragma_Name (Prag);
if Prag_Nam = Name_Initial_Condition then
Init_Cond := Prag;
elsif Prag_Nam = Name_Initializes then
Init := Prag;
end if;
Prag := Next_Pragma (Prag);
end loop;
-- Analyze the initialization related pragmas. Initializes must come
-- before Initial_Condition due to item dependencies.
if Present (Init) then
Analyze_Initializes_In_Decl_Part (Init);
end if;
if Present (Init_Cond) then
Analyze_Initial_Condition_In_Decl_Part (Init_Cond);
end if;
end if;
-- Check whether the lack of indicator Part_Of agrees with the placement
-- of the package instantiation with respect to the state space.
if Is_Generic_Instance (Pack_Id) then
Prag := Get_Pragma (Pack_Id, Pragma_Part_Of);
if No (Prag) then
Check_Missing_Part_Of (Pack_Id);
end if;
end if;
-- Restore the SPARK_Mode of the enclosing context after all delayed
-- pragmas have been analyzed.
Restore_SPARK_Mode (Mode);
end Analyze_Package_Contract;
--------------------------------- ---------------------------------
-- Analyze_Package_Declaration -- -- Analyze_Package_Declaration --
--------------------------------- ---------------------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2015, 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- --
...@@ -32,20 +32,6 @@ package Sem_Ch7 is ...@@ -32,20 +32,6 @@ package Sem_Ch7 is
procedure Analyze_Package_Specification (N : Node_Id); procedure Analyze_Package_Specification (N : Node_Id);
procedure Analyze_Private_Type_Declaration (N : Node_Id); procedure Analyze_Private_Type_Declaration (N : Node_Id);
procedure Analyze_Package_Body_Contract (Body_Id : Entity_Id);
-- 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
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 End_Package_Scope (P : Entity_Id); procedure End_Package_Scope (P : Entity_Id);
-- Calls Uninstall_Declarations, and then pops the scope stack -- Calls Uninstall_Declarations, and then pops the scope stack
......
...@@ -209,8 +209,12 @@ package Sem_Prag is ...@@ -209,8 +209,12 @@ package Sem_Prag is
-- uses Analyze_Global_In_Decl_Part as a starting point, then performs -- uses Analyze_Global_In_Decl_Part as a starting point, then performs
-- various consistency checks between Global and Refined_Global. -- various consistency checks between Global and Refined_Global.
procedure Analyze_Refined_State_In_Decl_Part (N : Node_Id); procedure Analyze_Refined_State_In_Decl_Part
-- Perform full analysis of delayed pragma Refined_State (N : Node_Id;
Freeze_Id : Entity_Id := Empty);
-- Perform full analysis of delayed pragma Refined_State. Freeze_Id denotes
-- the entity of [generic] package body or [generic] subprogram body which
-- caused "freezing" of the related contract where the pragma resides.
procedure Analyze_Test_Case_In_Decl_Part (N : Node_Id); procedure Analyze_Test_Case_In_Decl_Part (N : Node_Id);
-- Perform preanalysis of pragma Test_Case -- Perform preanalysis of pragma Test_Case
......
...@@ -49,32 +49,6 @@ package Sem_Util is ...@@ -49,32 +49,6 @@ package Sem_Util is
-- it the identifier of the block. Id denotes the generated entity. If the -- it the identifier of the block. Id denotes the generated entity. If the
-- block already has an identifier, Id returns the entity of its label. -- block already has an identifier, Id returns the entity of its label.
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 Add_Global_Declaration (N : Node_Id); procedure Add_Global_Declaration (N : Node_Id);
-- These procedures adds a declaration N at the library level, to be -- These procedures adds a declaration N at the library level, to be
-- elaborated before any other code in the unit. It is used for example -- elaborated before any other code in the unit. It is used for example
...@@ -276,6 +250,14 @@ package Sem_Util is ...@@ -276,6 +250,14 @@ package Sem_Util is
-- error message on node N. Used in object declarations, type conversions -- error message on node N. Used in object declarations, type conversions
-- and qualified expressions. -- and qualified expressions.
procedure Check_Function_With_Address_Parameter (Subp_Id : Entity_Id);
-- A subprogram that has an Address parameter and is declared in a Pure
-- package is not considered Pure, because the parameter may be used as a
-- pointer and the referenced data may change even if the address value
-- itself does not.
-- If the programmer gave an explicit Pure_Function pragma, then we respect
-- the pragma and leave the subprogram Pure.
procedure Check_Function_Writable_Actuals (N : Node_Id); procedure Check_Function_Writable_Actuals (N : Node_Id);
-- (Ada 2012): If the construct N has two or more direct constituents that -- (Ada 2012): If the construct N has two or more direct constituents that
-- are names or expressions whose evaluation may occur in an arbitrary -- are names or expressions whose evaluation may occur in an arbitrary
...@@ -322,19 +304,20 @@ package Sem_Util is ...@@ -322,19 +304,20 @@ package Sem_Util is
-- N is one of the statement forms that is a potentially blocking -- N is one of the statement forms that is a potentially blocking
-- operation. If it appears within a protected action, emit warning. -- operation. If it appears within a protected action, emit warning.
procedure Check_Function_With_Address_Parameter (Subp_Id : Entity_Id);
-- A subprogram that has an Address parameter and is declared in a Pure
-- package is not considered Pure, because the parameter may be used as a
-- pointer and the referenced data may change even if the address value
-- itself does not.
-- If the programmer gave an explicit Pure_Function pragma, then we respect
-- the pragma and leave the subprogram Pure.
procedure Check_Result_And_Post_State (Subp_Id : Entity_Id); procedure Check_Result_And_Post_State (Subp_Id : Entity_Id);
-- Determine whether the contract of subprogram Subp_Id mentions attribute -- Determine whether the contract of subprogram Subp_Id mentions attribute
-- 'Result and it contains an expression that evaluates differently in pre- -- 'Result and it contains an expression that evaluates differently in pre-
-- and post-state. -- and post-state.
procedure Check_Unused_Body_States (Body_Id : Entity_Id);
-- Verify that all abstract states and object declared in the state space
-- of a package body denoted by entity Body_Id are used as constituents.
-- Emit an error if this is not the case.
function Collect_Body_States (Body_Id : Entity_Id) return Elist_Id;
-- Gather the entities of all abstract states and objects declared in the
-- body state space of package body Body_Id.
procedure Check_Unprotected_Access procedure Check_Unprotected_Access
(Context : Node_Id; (Context : Node_Id;
Expr : Node_Id); Expr : Node_Id);
...@@ -434,11 +417,6 @@ package Sem_Util is ...@@ -434,11 +417,6 @@ package Sem_Util is
-- Return the corresponding spec of Decl when it denotes a package or a -- Return the corresponding spec of Decl when it denotes a package or a
-- subprogram [stub], or the defining entity of Decl. -- subprogram [stub], or the defining entity of Decl.
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.
function Current_Entity (N : Node_Id) return Entity_Id; function Current_Entity (N : Node_Id) return Entity_Id;
pragma Inline (Current_Entity); pragma Inline (Current_Entity);
-- Find the currently visible definition for a given identifier, that is to -- Find the currently visible definition for a given identifier, that is to
...@@ -1159,14 +1137,6 @@ package Sem_Util is ...@@ -1159,14 +1137,6 @@ package Sem_Util is
-- Inherit the rep item chain of type From_Typ without clobbering any -- Inherit the rep item chain of type From_Typ without clobbering any
-- existing rep items on Typ's chain. Typ is the destination type. -- existing rep items on Typ's chain. Typ is the destination type.
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 Insert_Explicit_Dereference (N : Node_Id); procedure Insert_Explicit_Dereference (N : Node_Id);
-- In a context that requires a composite or subprogram type and where a -- In a context that requires a composite or subprogram type and where a
-- prefix is an access type, rewrite the access type node N (which is the -- prefix is an access type, rewrite the access type node N (which is the
...@@ -1877,6 +1847,13 @@ package Sem_Util is ...@@ -1877,6 +1847,13 @@ package Sem_Util is
-- more there is at least one case in the generated code (the code for -- more there is at least one case in the generated code (the code for
-- array assignment in a loop) that depends on this suppression. -- array assignment in a loop) that depends on this suppression.
procedure Report_Unused_Body_States
(Body_Id : Entity_Id;
States : Elist_Id);
-- Emit errors for each abstract state or object found in list States that
-- is declared in package body Body_Id, but is not used as constituent in a
-- state refinement.
procedure Require_Entity (N : Node_Id); procedure Require_Entity (N : Node_Id);
-- N is a node which should have an entity value if it is an entity name. -- N is a node which should have an entity value if it is an entity name.
-- If not, then check if there were previous errors. If so, just fill -- If not, then check if there were previous errors. If so, just fill
......
...@@ -1860,6 +1860,14 @@ package body Sinfo is ...@@ -1860,6 +1860,14 @@ package body Sinfo is
return Flag11 (N); return Flag11 (N);
end Is_Expanded_Build_In_Place_Call; end Is_Expanded_Build_In_Place_Call;
function Is_Expanded_Contract
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
return Flag1 (N);
end Is_Expanded_Contract;
function Is_Finalization_Wrapper function Is_Finalization_Wrapper
(N : Node_Id) return Boolean is (N : Node_Id) return Boolean is
begin begin
...@@ -5073,6 +5081,14 @@ package body Sinfo is ...@@ -5073,6 +5081,14 @@ package body Sinfo is
Set_Flag11 (N, Val); Set_Flag11 (N, Val);
end Set_Is_Expanded_Build_In_Place_Call; end Set_Is_Expanded_Build_In_Place_Call;
procedure Set_Is_Expanded_Contract
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Contract);
Set_Flag1 (N, Val);
end Set_Is_Expanded_Contract;
procedure Set_Is_Finalization_Wrapper procedure Set_Is_Finalization_Wrapper
(N : Node_Id; Val : Boolean := True) is (N : Node_Id; Val : Boolean := True) is
begin begin
......
...@@ -1542,6 +1542,10 @@ package Sinfo is ...@@ -1542,6 +1542,10 @@ package Sinfo is
-- is called in a dispatching context. Used to prevent a formal/actual -- is called in a dispatching context. Used to prevent a formal/actual
-- mismatch when the call is rewritten as a dispatching call. -- mismatch when the call is rewritten as a dispatching call.
-- Is_Expanded_Contract (Flag1-Sem)
-- Present in N_Contract nodes. Set if the contract has already undergone
-- expansion activities.
-- Is_Asynchronous_Call_Block (Flag7-Sem) -- Is_Asynchronous_Call_Block (Flag7-Sem)
-- A flag set in a Block_Statement node to indicate that it is the -- A flag set in a Block_Statement node to indicate that it is the
-- expansion of an asynchronous entry call. Such a block needs cleanup -- expansion of an asynchronous entry call. Such a block needs cleanup
...@@ -7564,6 +7568,7 @@ package Sinfo is ...@@ -7564,6 +7568,7 @@ package Sinfo is
-- Pre_Post_Conditions (Node1-Sem) (set to Empty if none) -- Pre_Post_Conditions (Node1-Sem) (set to Empty if none)
-- Contract_Test_Cases (Node2-Sem) (set to Empty if none) -- Contract_Test_Cases (Node2-Sem) (set to Empty if none)
-- Classifications (Node3-Sem) (set to Empty if none) -- Classifications (Node3-Sem) (set to Empty if none)
-- Is_Expanded_Contract (Flag1-Sem)
-- Pre_Post_Conditions contains a collection of pragmas that correspond -- Pre_Post_Conditions contains a collection of pragmas that correspond
-- to pre- and postconditions associated with an entry or a subprogram -- to pre- and postconditions associated with an entry or a subprogram
...@@ -7592,9 +7597,11 @@ package Sinfo is ...@@ -7592,9 +7597,11 @@ package Sinfo is
-- Abstract_States -- Abstract_States
-- Async_Readers -- Async_Readers
-- Async_Writers -- Async_Writers
-- Constant_After_Elaboration
-- Depends -- Depends
-- Effective_Reads -- Effective_Reads
-- Effective_Writes -- Effective_Writes
-- Extensions_Visible
-- Global -- Global
-- Initial_Condition -- Initial_Condition
-- Initializes -- Initializes
...@@ -7602,6 +7609,7 @@ package Sinfo is ...@@ -7602,6 +7609,7 @@ package Sinfo is
-- Refined_Depends -- Refined_Depends
-- Refined_Global -- Refined_Global
-- Refined_States -- Refined_States
-- Volatile_Function
-- The ordering is in LIFO fashion. -- The ordering is in LIFO fashion.
------------------- -------------------
...@@ -9322,6 +9330,9 @@ package Sinfo is ...@@ -9322,6 +9330,9 @@ package Sinfo is
function Is_Expanded_Build_In_Place_Call function Is_Expanded_Build_In_Place_Call
(N : Node_Id) return Boolean; -- Flag11 (N : Node_Id) return Boolean; -- Flag11
function Is_Expanded_Contract
(N : Node_Id) return Boolean; -- Flag1
function Is_Finalization_Wrapper function Is_Finalization_Wrapper
(N : Node_Id) return Boolean; -- Flag9 (N : Node_Id) return Boolean; -- Flag9
...@@ -10348,6 +10359,9 @@ package Sinfo is ...@@ -10348,6 +10359,9 @@ package Sinfo is
procedure Set_Is_Expanded_Build_In_Place_Call procedure Set_Is_Expanded_Build_In_Place_Call
(N : Node_Id; Val : Boolean := True); -- Flag11 (N : Node_Id; Val : Boolean := True); -- Flag11
procedure Set_Is_Expanded_Contract
(N : Node_Id; Val : Boolean := True); -- Flag1
procedure Set_Is_Finalization_Wrapper procedure Set_Is_Finalization_Wrapper
(N : Node_Id; Val : Boolean := True); -- Flag9 (N : Node_Id; Val : Boolean := True); -- Flag9
...@@ -12748,6 +12762,7 @@ package Sinfo is ...@@ -12748,6 +12762,7 @@ package Sinfo is
pragma Inline (Is_Elsif); pragma Inline (Is_Elsif);
pragma Inline (Is_Entry_Barrier_Function); pragma Inline (Is_Entry_Barrier_Function);
pragma Inline (Is_Expanded_Build_In_Place_Call); pragma Inline (Is_Expanded_Build_In_Place_Call);
pragma Inline (Is_Expanded_Contract);
pragma Inline (Is_Finalization_Wrapper); pragma Inline (Is_Finalization_Wrapper);
pragma Inline (Is_Folded_In_Parser); pragma Inline (Is_Folded_In_Parser);
pragma Inline (Is_Generic_Contract_Pragma); pragma Inline (Is_Generic_Contract_Pragma);
...@@ -13085,6 +13100,7 @@ package Sinfo is ...@@ -13085,6 +13100,7 @@ package Sinfo is
pragma Inline (Set_Is_Elsif); pragma Inline (Set_Is_Elsif);
pragma Inline (Set_Is_Entry_Barrier_Function); pragma Inline (Set_Is_Entry_Barrier_Function);
pragma Inline (Set_Is_Expanded_Build_In_Place_Call); pragma Inline (Set_Is_Expanded_Build_In_Place_Call);
pragma Inline (Set_Is_Expanded_Contract);
pragma Inline (Set_Is_Finalization_Wrapper); pragma Inline (Set_Is_Finalization_Wrapper);
pragma Inline (Set_Is_Folded_In_Parser); pragma Inline (Set_Is_Folded_In_Parser);
pragma Inline (Set_Is_Generic_Contract_Pragma); pragma Inline (Set_Is_Generic_Contract_Pragma);
......
...@@ -127,7 +127,7 @@ package body Switch.B is ...@@ -127,7 +127,7 @@ package body Switch.B is
-- A little check, "gnat" at the start of a switch is not allowed except -- A little check, "gnat" at the start of a switch is not allowed except
-- for the compiler -- for the compiler
if Switch_Chars'Last >= Ptr + 3 if Max >= Ptr + 3
and then Switch_Chars (Ptr .. Ptr + 3) = "gnat" and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"
then then
Osint.Fail ("invalid switch: """ & Switch_Chars & """" Osint.Fail ("invalid switch: """ & Switch_Chars & """"
...@@ -229,8 +229,28 @@ package body Switch.B is ...@@ -229,8 +229,28 @@ package body Switch.B is
-- Processing for E switch -- Processing for E switch
when 'E' => when 'E' =>
Ptr := Ptr + 1;
-- -E is equivalent to -Ea (see below)
Exception_Tracebacks := True; Exception_Tracebacks := True;
Ptr := Ptr + 1;
if Ptr <= Max then
case Switch_Chars (Ptr) is
-- -Ea sets Exception_Tracebacks
when 'a' => null;
-- -Es sets both Exception_Tracebacks and
-- Exception_Tracebacks_Symbolic.
when 's' => Exception_Tracebacks_Symbolic := True;
when others => Bad_Switch (Switch_Chars);
end case;
Ptr := Ptr + 1;
end if;
-- Processing for F switch -- Processing for F switch
...@@ -542,13 +562,11 @@ package body Switch.B is ...@@ -542,13 +562,11 @@ package body Switch.B is
declare declare
Src_Path_Name : constant String_Ptr := Src_Path_Name : constant String_Ptr :=
Get_RTS_Search_Dir Get_RTS_Search_Dir
(Switch_Chars (Switch_Chars (Ptr + 1 .. Max),
(Ptr + 1 .. Switch_Chars'Last),
Include); Include);
Lib_Path_Name : constant String_Ptr := Lib_Path_Name : constant String_Ptr :=
Get_RTS_Search_Dir Get_RTS_Search_Dir
(Switch_Chars (Switch_Chars (Ptr + 1 .. Max),
(Ptr + 1 .. Switch_Chars'Last),
Objects); Objects);
begin begin
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2007, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2015, 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- --
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
package Switch.B is package Switch.B is
procedure Scan_Binder_Switches (Switch_Chars : String); procedure Scan_Binder_Switches (Switch_Chars : String);
-- Procedures to scan out binder switches stored in the given string. -- Procedure to scan out binder switches stored in the given string.
-- The first character is known to be a valid switch character, and there -- The first character is known to be a valid switch character, and there
-- are no blanks or other switch terminator characters in the string, so -- are no blanks or other switch terminator characters in the string, so
-- the entire string should consist of valid switch characters, except that -- the entire string should consist of valid switch characters, except that
......
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