summaryrefslogtreecommitdiff
path: root/gcc/ada/par-ch5.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-09 14:59:55 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-09 14:59:55 +0000
commiteba2aae511fc844543f6d2845fac82544617f76d (patch)
tree4cb47b83e2b0f42ab42d54d9b0a4fb49b2a68d93 /gcc/ada/par-ch5.adb
parent8e14cc65d0226cf4a44421a8183cd0bccd651897 (diff)
downloadgcc-eba2aae511fc844543f6d2845fac82544617f76d.tar.gz
2010-10-09 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 165222 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@165232 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/par-ch5.adb')
-rw-r--r--gcc/ada/par-ch5.adb25
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
index 428dc7890aa..04e1005e593 100644
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -83,7 +83,8 @@ package body Ch5 is
-- 5.1 Sequence of Statements --
---------------------------------
- -- SEQUENCE_OF_STATEMENTS ::= STATEMENT {STATEMENT}
+ -- SEQUENCE_OF_STATEMENTS ::= STATEMENT {STATEMENT} {LABEL}
+ -- Note: the final label is an Ada 2012 addition.
-- STATEMENT ::=
-- {LABEL} SIMPLE_STATEMENT | {LABEL} COMPOUND_STATEMENT
@@ -149,6 +150,12 @@ package body Ch5 is
-- is required. It is initialized from the Sreq flag, and modified as
-- statements are scanned (a statement turns it off, and a label turns
-- it back on again since a statement must follow a label).
+ -- Note : this final requirement is lifted in Ada 2012.
+
+ Statement_Seen : Boolean;
+ -- In Ada 2012, a label can end a sequence of statements, but the
+ -- sequence cannot contain only labels. This flag is set whenever a
+ -- label is encountered, to enforce this rule at the end of a sequence.
Declaration_Found : Boolean := False;
-- This flag is set True if a declaration is encountered, so that the
@@ -222,8 +229,10 @@ package body Ch5 is
if Ada_Version >= Ada_2012
and then not Is_Empty_List (Statement_List)
- and then (Nkind (Last (Statement_List)) = N_Label
- or else All_Pragmas)
+ and then
+ ((Nkind (Last (Statement_List)) = N_Label
+ and then Statement_Seen)
+ or else All_Pragmas)
then
declare
Null_Stm : constant Node_Id :=
@@ -233,8 +242,6 @@ package body Ch5 is
Append_To (Statement_List, Null_Stm);
end;
- -- All pragmas is OK on
-
-- If not Ada 2012, or not special case above, give error message
else
@@ -249,6 +256,7 @@ package body Ch5 is
begin
Statement_List := New_List;
Statement_Required := SS_Flags.Sreq;
+ Statement_Seen := False;
loop
Ignore (Tok_Semicolon);
@@ -765,8 +773,15 @@ package body Ch5 is
Statement_Required := False;
-- Label starting with << which must precede real statement
+ -- Note: in Ada 2012, the label may end the sequence.
when Tok_Less_Less =>
+ if Present (Last (Statement_List))
+ and then Nkind (Last (Statement_List)) /= N_Label
+ then
+ Statement_Seen := True;
+ end if;
+
Append_To (Statement_List, P_Label);
Statement_Required := True;