Commit 3db39676 by Yannick Moy Committed by Arnaud Charlet

sem_ch13.adb (Add_Invariants): Analyze the invariant expression as an assertion expression.

2012-10-01  Yannick Moy  <moy@adacore.com>

	* sem_ch13.adb (Add_Invariants): Analyze the invariant expression
	as an assertion expression.
	* sem_ch3.adb / sem_ch3.ads (Preanalyze_Assert_Expression):
	New procedure that wraps a call to Preanalyze_Spec_Expression
	for assertion expressions, so that In_Assertion_Expr can be
	properly adjusted.
	* sem_prag.adb (Analyze_PPC_In_Decl_Part
	Check_Precondition_Postcondition Preanalyze_CTC_Args): Call the
	new Preanalyze_Assert_Expression.

From-SVN: r191898
parent 3f5e1e07
2012-10-01 Yannick Moy <moy@adacore.com>
* sem_ch13.adb (Add_Invariants): Analyze the invariant expression
as an assertion expression.
* sem_ch3.adb / sem_ch3.ads (Preanalyze_Assert_Expression):
New procedure that wraps a call to Preanalyze_Spec_Expression
for assertion expressions, so that In_Assertion_Expr can be
properly adjusted.
* sem_prag.adb (Analyze_PPC_In_Decl_Part
Check_Precondition_Postcondition Preanalyze_CTC_Args): Call the
new Preanalyze_Assert_Expression.
2012-10-01 Robert Dewar <dewar@adacore.com> 2012-10-01 Robert Dewar <dewar@adacore.com>
* checks.ads: Minor reformatting. * checks.ads: Minor reformatting.
......
...@@ -5058,7 +5058,7 @@ package body Sem_Ch13 is ...@@ -5058,7 +5058,7 @@ package body Sem_Ch13 is
-- at the end of the private part and has the wrong visibility. -- at the end of the private part and has the wrong visibility.
Set_Parent (Exp, N); Set_Parent (Exp, N);
Preanalyze_Spec_Expression (Exp, Standard_Boolean); Preanalyze_Assert_Expression (Exp, Standard_Boolean);
-- Build first two arguments for Check pragma -- Build first two arguments for Check pragma
......
...@@ -19306,6 +19306,17 @@ package body Sem_Ch3 is ...@@ -19306,6 +19306,17 @@ package body Sem_Ch3 is
end if; end if;
end Check_Anonymous_Access_Components; end Check_Anonymous_Access_Components;
----------------------------------
-- Preanalyze_Assert_Expression --
----------------------------------
procedure Preanalyze_Assert_Expression (N : Node_Id; T : Entity_Id) is
begin
In_Assertion_Expr := In_Assertion_Expr + 1;
Preanalyze_Spec_Expression (N, T);
In_Assertion_Expr := In_Assertion_Expr - 1;
end Preanalyze_Assert_Expression;
-------------------------------- --------------------------------
-- Preanalyze_Spec_Expression -- -- Preanalyze_Spec_Expression --
-------------------------------- --------------------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2012, 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- --
...@@ -246,6 +246,10 @@ package Sem_Ch3 is ...@@ -246,6 +246,10 @@ package Sem_Ch3 is
-- This mechanism is also used for aspect specifications that have an -- This mechanism is also used for aspect specifications that have an
-- expression parameter that needs similar preanalysis. -- expression parameter that needs similar preanalysis.
procedure Preanalyze_Assert_Expression (N : Node_Id; T : Entity_Id);
-- Wrapper on Preanalyze_Spec_Expression for assertion expressions, so that
-- In_Assertion_Expr can be properly adjusted.
procedure Process_Full_View (N : Node_Id; Full_T, Priv_T : Entity_Id); procedure Process_Full_View (N : Node_Id; Full_T, Priv_T : Entity_Id);
-- Process some semantic actions when the full view of a private type is -- Process some semantic actions when the full view of a private type is
-- encountered and analyzed. The first action is to create the full views -- encountered and analyzed. The first action is to create the full views
......
...@@ -286,9 +286,7 @@ package body Sem_Prag is ...@@ -286,9 +286,7 @@ package body Sem_Prag is
-- Preanalyze the boolean expression, we treat this as a spec expression -- Preanalyze the boolean expression, we treat this as a spec expression
-- (i.e. similar to a default expression). -- (i.e. similar to a default expression).
In_Assertion_Expr := In_Assertion_Expr + 1; Preanalyze_Assert_Expression (Get_Pragma_Arg (Arg1), Standard_Boolean);
Preanalyze_Spec_Expression (Get_Pragma_Arg (Arg1), Standard_Boolean);
In_Assertion_Expr := In_Assertion_Expr - 1;
-- In ASIS mode, for a pragma generated from a source aspect, also -- In ASIS mode, for a pragma generated from a source aspect, also
-- analyze the original aspect expression. -- analyze the original aspect expression.
...@@ -296,7 +294,7 @@ package body Sem_Prag is ...@@ -296,7 +294,7 @@ package body Sem_Prag is
if ASIS_Mode if ASIS_Mode
and then Present (Corresponding_Aspect (N)) and then Present (Corresponding_Aspect (N))
then then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Expression (Corresponding_Aspect (N)), Standard_Boolean); (Expression (Corresponding_Aspect (N)), Standard_Boolean);
end if; end if;
...@@ -2178,7 +2176,7 @@ package body Sem_Prag is ...@@ -2178,7 +2176,7 @@ package body Sem_Prag is
then then
-- Analyze pragma expression for correctness and for ASIS use -- Analyze pragma expression for correctness and for ASIS use
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Get_Pragma_Arg (Arg1), Standard_Boolean); (Get_Pragma_Arg (Arg1), Standard_Boolean);
-- In ASIS mode, for a pragma generated from a source aspect, -- In ASIS mode, for a pragma generated from a source aspect,
...@@ -2187,7 +2185,7 @@ package body Sem_Prag is ...@@ -2187,7 +2185,7 @@ package body Sem_Prag is
if ASIS_Mode if ASIS_Mode
and then Present (Corresponding_Aspect (N)) and then Present (Corresponding_Aspect (N))
then then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Expression (Corresponding_Aspect (N)), Standard_Boolean); (Expression (Corresponding_Aspect (N)), Standard_Boolean);
end if; end if;
end if; end if;
...@@ -6773,7 +6771,8 @@ package body Sem_Prag is ...@@ -6773,7 +6771,8 @@ package body Sem_Prag is
-- pragma Check (Assertion, condition [, msg]); -- pragma Check (Assertion, condition [, msg]);
-- So rewrite pragma in this manner, and analyze the result -- So rewrite pragma in this manner, transfer the message
-- argument if present, and analyze the result
Expr := Get_Pragma_Arg (Arg1); Expr := Get_Pragma_Arg (Arg1);
Newa := New_List ( Newa := New_List (
...@@ -6785,8 +6784,7 @@ package body Sem_Prag is ...@@ -6785,8 +6784,7 @@ package body Sem_Prag is
if Arg_Count > 1 then if Arg_Count > 1 then
Check_Optional_Identifier (Arg2, Name_Message); Check_Optional_Identifier (Arg2, Name_Message);
Analyze_And_Resolve (Get_Pragma_Arg (Arg2), Standard_String); Append_To (Newa, New_Copy_Tree (Arg2));
Append_To (Newa, Relocate_Node (Arg2));
end if; end if;
Rewrite (N, Rewrite (N,
...@@ -15532,27 +15530,27 @@ package body Sem_Prag is ...@@ -15532,27 +15530,27 @@ package body Sem_Prag is
-- expressions (i.e. similar to a default expression). -- expressions (i.e. similar to a default expression).
if Present (Arg_Req) then if Present (Arg_Req) then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Get_Pragma_Arg (Arg_Req), Standard_Boolean); (Get_Pragma_Arg (Arg_Req), Standard_Boolean);
-- In ASIS mode, for a pragma generated from a source aspect, also -- In ASIS mode, for a pragma generated from a source aspect, also
-- analyze the original aspect expression. -- analyze the original aspect expression.
if ASIS_Mode and then Present (Corresponding_Aspect (N)) then if ASIS_Mode and then Present (Corresponding_Aspect (N)) then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Original_Node (Get_Pragma_Arg (Arg_Req)), Standard_Boolean); (Original_Node (Get_Pragma_Arg (Arg_Req)), Standard_Boolean);
end if; end if;
end if; end if;
if Present (Arg_Ens) then if Present (Arg_Ens) then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Get_Pragma_Arg (Arg_Ens), Standard_Boolean); (Get_Pragma_Arg (Arg_Ens), Standard_Boolean);
-- In ASIS mode, for a pragma generated from a source aspect, also -- In ASIS mode, for a pragma generated from a source aspect, also
-- analyze the original aspect expression. -- analyze the original aspect expression.
if ASIS_Mode and then Present (Corresponding_Aspect (N)) then if ASIS_Mode and then Present (Corresponding_Aspect (N)) then
Preanalyze_Spec_Expression Preanalyze_Assert_Expression
(Original_Node (Get_Pragma_Arg (Arg_Ens)), Standard_Boolean); (Original_Node (Get_Pragma_Arg (Arg_Ens)), Standard_Boolean);
end if; end if;
end if; end if;
......
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