From: Robert Dewar Date: Thu, 9 Sep 2010 09:38:32 +0000 (+0000) Subject: par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no null statement... X-Git-Tag: releases/gcc-4.6.0~4517 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=821b8ef47bc9cd196526e61b9426be24ffdd6eca;p=thirdparty%2Fgcc.git par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no null statement after label. 2010-09-09 Robert Dewar * par-ch5.adb (Test_Statement_Required): Deal with Ada 2012 allowing no null statement after label. * sinfo.ads: Minor comment updates. From-SVN: r164057 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c0c3e104c317..6bdf36956746 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2010-09-09 Robert Dewar + + * 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 * nlists.ads, nlists.adb (In_Same_List): New function. diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb index d9d64d7f542c..bbac0327ebcd 100644 --- a/gcc/ada/par-ch5.adb +++ b/gcc/ada/par-ch5.adb @@ -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; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index cb358c4d75b3..707bf6480d9e 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -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 -- -------------------------------------