sem_prag.adb (Analyze_PPC_In_Decl_Part): In ASIS mode...
authorEd Schonberg <schonberg@adacore.com>
Mon, 8 Jul 2013 07:39:55 +0000 (07:39 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 8 Jul 2013 07:39:55 +0000 (09:39 +0200)
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

gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb

index 5d222e79e9422e4032471d23db7a1b4219fb52c0..a6a808faa56e33551dded4eb0325b4c6ed40df3d 100644 (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.
index 5378fa3ff74fba37a0fd4b29f995695b80eec5e5..2cb3d29dc664da371f0cb2bc88751481d0fcc6d2 100644 (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
index 36c3d7fc2b0a003cc507709221c6027c485bf38c..16bccace7ee112d1458ec0f9e0ba38e21ee28bae 100644 (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