From 1bc331122b9f6a30124d1deb32a7af5eef006a00 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 8 Jul 2013 07:39:55 +0000 Subject: [PATCH] sem_prag.adb (Analyze_PPC_In_Decl_Part): In ASIS mode... 2013-07-08 Ed Schonberg * 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 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/sem_ch13.adb | 7 ++----- gcc/ada/sem_prag.adb | 10 ++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5d222e79e94..a6a808faa56 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2013-07-08 Ed Schonberg + + * 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 * aspects.adb: Add an entry for SPARK_Mode in table Canonical_Aspect. diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 5378fa3ff74..2cb3d29dc66 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 36c3d7fc2b0..16bccace7ee 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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 -- 2.30.2