]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sem_ch13.adb (Analyze_Aspect_Specifications): For a Pre/Post aspect that applies...
authorThomas Quinot <quinot@adacore.com>
Wed, 2 Jan 2013 09:39:36 +0000 (09:39 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 2 Jan 2013 09:39:36 +0000 (10:39 +0100)
2013-01-02  Thomas Quinot  <quinot@adacore.com>

* sem_ch13.adb (Analyze_Aspect_Specifications): For a Pre/Post
aspect that applies to a library subprogram, prepend corresponding
pragma to the Pragmas_After list, in order for split AND THEN
sections to be processed in the expected order.

From-SVN: r194783

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

index e92b0d765a68acf58eb180be5394099212eb2762..607bcb83fc751f1552139dac1f24dcd63c60f067 100644 (file)
@@ -1,3 +1,10 @@
+2013-01-02  Thomas Quinot  <quinot@adacore.com>
+
+       * sem_ch13.adb (Analyze_Aspect_Specifications): For a Pre/Post
+       aspect that applies to a library subprogram, prepend corresponding
+       pragma to the Pragmas_After list, in order for split AND THEN
+       sections to be processed in the expected order.
+
 2013-01-02  Thomas Quinot  <quinot@adacore.com>
 
        * exp_prag.adb (Expand_Pragma_Check): The statements generated
index 235af1893849a9b72cf39b9fb95236718d59cd95..221c86627919bd67078cf5d35f2581a3a8cdaf55 100644 (file)
@@ -1602,10 +1602,21 @@ package body Sem_Ch13 is
                   --  with delay of visibility for the expression analysis.
 
                   --  If the entity is a library-level subprogram, the pre/
-                  --  postconditions must be treated as late pragmas.
+                  --  postconditions must be treated as late pragmas. Note
+                  --  that they must be prepended, not appended, to the list,
+                  --  so that split AND THEN sections are processed in the
+                  --  correct order.
 
                   if Nkind (Parent (N)) = N_Compilation_Unit then
-                     Add_Global_Declaration (Aitem);
+                     declare
+                        Aux : constant Node_Id := Aux_Decls_Node (Parent (N));
+                     begin
+                        if No (Pragmas_After (Aux)) then
+                           Set_Pragmas_After (Aux, New_List);
+                        end if;
+
+                        Prepend (Aitem, Pragmas_After (Aux));
+                     end;
 
                   --  If it is a subprogram body, add pragmas to list of
                   --  declarations in body.
@@ -1930,7 +1941,7 @@ package body Sem_Ch13 is
 
                   else
                      if No (Pragmas_After (Aux)) then
-                        Set_Pragmas_After (Aux, Empty_List);
+                        Set_Pragmas_After (Aux, New_List);
                      end if;
 
                      Append (Aitem, Pragmas_After (Aux));