diff mbox

[Ada] Do not require null after label in Ada 2012 mode

Message ID 20100909093840.GA4639@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Sept. 9, 2010, 9:38 a.m. UTC
This patch implements the new Ada 2012 feature that no longer
requires a statement to follow a label.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-09-09  Robert Dewar  <dewar@adacore.com>

	* par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no
	null statement after label.
diff mbox

Patch

Index: par-ch5.adb
===================================================================
--- par-ch5.adb	(revision 164056)
+++ par-ch5.adb	(working copy)
@@ -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;