sem_prag.adb (Analyze_PPC_In_Decl_Part): In ASIS mode...

2013-07-08  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Analyze_PPC_In_Decl_Part): In ASIS mode,
	pre-analyze only the original expression attached to the source
	aspect, not the relocated expression of the pragma, to prevent
	malformed trees in ASIS mode.
	* sem_ch13.adb (Analyze_Aspect_Specifications): Revert previous
	patch: the expression in the aspect for pre/post must be relocated
	to the pragma for proper analysis.

From-SVN: r200752
This commit is contained in:
Ed Schonberg 2013-07-08 07:39:55 +00:00 committed by Arnaud Charlet
parent 930b700ba2
commit 1bc331122b
3 changed files with 18 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2013-07-08 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_PPC_In_Decl_Part): In ASIS mode,
pre-analyze only the original expression attached to the source
aspect, not the relocated expression of the pragma, to prevent
malformed trees in ASIS mode.
* sem_ch13.adb (Analyze_Aspect_Specifications): Revert previous
patch: the expression in the aspect for pre/post must be relocated
to the pragma for proper analysis.
2013-07-05 Hristian Kirtchev <kirtchev@adacore.com>
* aspects.adb: Add an entry for SPARK_Mode in table Canonical_Aspect.

View file

@ -1809,16 +1809,13 @@ package body Sem_Ch13 is
end loop;
end if;
-- Build the precondition/postcondition pragma. We copy
-- the expression to avoid sharing between the original
-- aspect and the pragma node, because in ASIS_Mode both
-- will be independently analyzed.
-- Build the precondition/postcondition pragma.
Make_Aitem_Pragma
(Pragma_Argument_Associations => New_List (
Make_Pragma_Argument_Association (Eloc,
Chars => Name_Check,
Expression => New_Copy_Tree (Expr))),
Expression => Relocate_Node (Expr))),
Pragma_Name => Pname);
-- Add message unless exception messages are suppressed

View file

@ -1718,14 +1718,16 @@ package body Sem_Prag is
-- Preanalyze the boolean expression, we treat this as a spec expression
-- (i.e. similar to a default expression).
Preanalyze_Assert_Expression (Get_Pragma_Arg (Arg1), Standard_Boolean);
-- In ASIS mode, for a pragma generated from a source aspect, also
-- analyze the original aspect expression.
-- In ASIS mode, for a pragma generated from a source aspect, analyze
-- directly the the original aspect expression, which is shared with
-- the generated pragma.
if ASIS_Mode and then Present (Corresponding_Aspect (N)) then
Preanalyze_Assert_Expression
(Expression (Corresponding_Aspect (N)), Standard_Boolean);
else
Preanalyze_Assert_Expression
(Get_Pragma_Arg (Arg1), Standard_Boolean);
end if;
-- For a class-wide condition, a reference to a controlling formal must