sem_prag.adb (Analyze_Pragma): Do not output the characters of an illegal argument...
authorHristian Kirtchev <kirtchev@adacore.com>
Tue, 6 Nov 2012 09:38:48 +0000 (09:38 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 6 Nov 2012 09:38:48 +0000 (10:38 +0100)
2012-11-06  Hristian Kirtchev  <kirtchev@adacore.com>

* sem_prag.adb (Analyze_Pragma): Do not
output the characters of an illegal argument as it may not have
characters to begin with.

2012-11-06  Hristian Kirtchev  <kirtchev@adacore.com>

* exp_prag.adb (Expand_Pragma_Loop_Assertion):
Change the order of argument processing to avoid disappearing
increase / decrease expressions.

From-SVN: r193212

gcc/ada/ChangeLog
gcc/ada/exp_prag.adb
gcc/ada/sem_prag.adb

index bf1db35..a07bc70 100644 (file)
@@ -1,5 +1,17 @@
 2012-11-06  Hristian Kirtchev  <kirtchev@adacore.com>
 
+       * sem_prag.adb (Analyze_Pragma): Do not
+       output the characters of an illegal argument as it may not have
+       characters to begin with.
+
+2012-11-06  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * exp_prag.adb (Expand_Pragma_Loop_Assertion):
+       Change the order of argument processing to avoid disappearing
+       increase / decrease expressions.
+
+2012-11-06  Hristian Kirtchev  <kirtchev@adacore.com>
+
        * exp_prag.adb: Add with and use clause for Sem_Ch8.
        (Expand_N_Pragma): Add a new variant to expand pragma Loop_Assertion.
        (Expand_Pragma_Loop_Assertion): New routine.
index e7b16a9..ae743c3 100644 (file)
@@ -1076,10 +1076,12 @@ package body Exp_Prag is
 
       Arg := First (Args);
       while Present (Arg) loop
-         if No (Invar) or else Chars (Arg) = Name_Invariant then
-            Invar := Expression (Arg);
-         else
+         if Chars (Arg) = Name_Increases
+           or else Chars (Arg) = Name_Decreases
+         then
             Process_Increase_Decrease (Arg, Is_Last => Arg = Last_Arg);
+         else
+            Invar := Expression (Arg);
          end if;
 
          Next (Arg);
@@ -1088,12 +1090,14 @@ package body Exp_Prag is
       --  Verify the invariant expression, generate:
       --    pragma Assert (<Invar>);
 
-      Insert_Action (N,
-        Make_Pragma (Loc,
-          Chars                        => Name_Assert,
-          Pragma_Argument_Associations => New_List (
-            Make_Pragma_Argument_Association (Loc,
-              Expression => Relocate_Node (Invar)))));
+      if Present (Invar) then
+         Insert_Action (N,
+           Make_Pragma (Loc,
+             Chars                        => Name_Assert,
+             Pragma_Argument_Associations => New_List (
+               Make_Pragma_Argument_Association (Loc,
+                 Expression => Relocate_Node (Invar)))));
+      end if;
 
       --  Construct the segment which stores the old values of all expressions.
       --  Generate:
index 2d66057..c2392cb 100644 (file)
@@ -11335,8 +11335,12 @@ package body Sem_Prag is
                --  relocated during expansion and analyzed in their new
                --  context.
 
-               if Chars (Arg) = Name_Invariant or else Arg_Count = 1 then
-
+               if Chars (Arg) = Name_Invariant
+                 or else
+                   (Arg_Count = 1
+                      and then Chars (Arg) /= Name_Increases
+                      and then Chars (Arg) /= Name_Decreases)
+               then
                   --  Only one invariant is allowed in the pragma
 
                   if Seen then
@@ -11355,7 +11359,7 @@ package body Sem_Prag is
                --  Illegal argument
 
                else
-                  Error_Pragma_Arg ("argument not allowed in pragma %", Arg);
+                  Error_Pragma_Arg ("argument not allowed in pragma %", Arg);
                end if;
 
                Next (Arg);