]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no null statement...
authorRobert Dewar <dewar@adacore.com>
Thu, 9 Sep 2010 09:38:32 +0000 (09:38 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 9 Sep 2010 09:38:32 +0000 (11:38 +0200)
2010-09-09  Robert Dewar  <dewar@adacore.com>

* par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no
null statement after label.
* sinfo.ads: Minor comment updates.

From-SVN: r164057

gcc/ada/ChangeLog
gcc/ada/par-ch5.adb
gcc/ada/sinfo.ads

index c0c3e104c3171f9d01344f72ce870825ac6c98d7..6bdf3695674624d86516d8974fa0b17a91be37d6 100644 (file)
@@ -1,3 +1,9 @@
+2010-09-09  Robert Dewar  <dewar@adacore.com>
+
+       * par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no
+       null statement after label.
+       * sinfo.ads: Minor comment updates.
+
 2010-09-09  Robert Dewar  <dewar@adacore.com>
 
        * nlists.ads, nlists.adb (In_Same_List): New function.
index d9d64d7f542c5a310a58a93ac7b0f978ecdb11f6..bbac0327ebcd5db4cd539a8a06ec97b95e99d78a 100644 (file)
@@ -193,8 +193,27 @@ package body Ch5 is
       procedure Test_Statement_Required is
       begin
          if Statement_Required then
-            Error_Msg_BC -- CODEFIX
-              ("statement expected");
+
+            --  Check no statement required after label in Ada 2012
+
+            if Ada_Version >= Ada_2012
+              and then not Is_Empty_List (Statement_List)
+              and then Nkind (Last (Statement_List)) = N_Label
+            then
+               declare
+                  Null_Stm : constant Node_Id :=
+                               Make_Null_Statement (Token_Ptr);
+               begin
+                  Set_Comes_From_Source (Null_Stm, False);
+                  Append_To (Statement_List, Null_Stm);
+               end;
+
+            --  If not Ada 2012, or not special case above, give error message
+
+            else
+               Error_Msg_BC -- CODEFIX
+                 ("statement expected");
+            end if;
          end if;
       end Test_Statement_Required;
 
index cb358c4d75b389fe4053c2f024eca674f9fd5b2a..707bf6480d9e7a608f2481813c9f80bd34611c2e 100644 (file)
@@ -3911,6 +3911,10 @@ package Sinfo is
       --  Identifier (Node1) direct name of statement identifier
       --  Exception_Junk (Flag8-Sem)
 
+      --  Note: Before Ada 2012, a label is always followed by a statement,
+      --  and this is true in the tree even in Ada 2012 mode (the parser
+      --  inserts a null statement marked with Comes_From_Source False).
+
       -------------------------------
       -- 5.1  Statement Identifier --
       -------------------------------
@@ -4006,6 +4010,11 @@ package Sinfo is
       --  Alternatives (List4)
       --  End_Span (Uint5) (set to No_Uint if expander generated)
 
+      --  Note: Before Ada 2012, a pragma in a statement sequence is always
+      --  followed by a statement, and this is true in the tree even in Ada
+      --  2012 mode (the parser inserts a null statement marked with the flag
+      --  Comes_From_Source False).
+
       -------------------------------------
       -- 5.4  Case Statement Alternative --
       -------------------------------------