aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/types.ads
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2022-06-29 17:06:47 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2022-07-12 12:24:14 +0000
commit0ff936fe86ddff4d4a95a4ca9eda85ad0287ffa5 (patch)
tree68fc6f0d4c7fd847c7dabfc99864192cd14cb828 /gcc/ada/types.ads
parent2b98bb583fbf9110e7282c1221448c15efb4bd2e (diff)
downloadgcc-0ff936fe86ddff4d4a95a4ca9eda85ad0287ffa5.zip
gcc-0ff936fe86ddff4d4a95a4ca9eda85ad0287ffa5.tar.gz
gcc-0ff936fe86ddff4d4a95a4ca9eda85ad0287ffa5.tar.bz2
[Ada] Ada 2020: Allow declarative items mixed with statements
This patch implements a syntactic language extension that allows declarative items to appear in a sequence of statements. For example: for X in S'Range loop Item : Character renames S (X); Item := Transform (Item); end loop; Previously, declare/begin/end was required, which is just noise. gcc/ada/ * par.adb (P_Declarative_Items): New function to parse a sequence of declarative items. (P_Sequence_Of_Statements): Add Handled flag, to indicate whether to wrap the result in a block statement. * par-ch3.adb (P_Declarative_Item): Rename P_Declarative_Items to be P_Declarative_Item, because it really only parses a single declarative item, and to avoid conflict with the new P_Declarative_Items. Add In_Statements. We keep the old error-recovery mechanisms in place when In_Statements is False. When True, we don't want to complain about statements, because we are parsing a sequence of statements. (P_Identifier_Declarations): If In_Statements, and we see what looks like a statement, we no longer give an error. We return to P_Sequence_Of_Statements with Done = True, so it can parse the statement. * par-ch5.adb (P_Sequence_Of_Statements): Call P_Declarative_Items to parse declarative items that appear in the statement list. Remove error handling code that complained about such items. Check some errors conservatively. Wrap the result in a block statement when necessary. * par-ch11.adb (P_Handled_Sequence_Of_Statements): Pass Handled => True to P_Sequence_Of_Statements. * types.ads (No, Present): New functions for querying Source_Ptrs (equal, not equal No_Location).
Diffstat (limited to 'gcc/ada/types.ads')
-rw-r--r--gcc/ada/types.ads4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads
index 9ae1797..aae51a2 100644
--- a/gcc/ada/types.ads
+++ b/gcc/ada/types.ads
@@ -247,6 +247,10 @@ package Types is
-- (very often we conditionalize so that we set No_Location in normal mode
-- and the corresponding source line in -gnatD mode).
+ function No (Loc : Source_Ptr) return Boolean is (Loc = No_Location);
+ function Present (Loc : Source_Ptr) return Boolean is (not No (Loc));
+ -- Tests for No_Location / not No_Location
+
Standard_Location : constant Source_Ptr := -2;
-- Used for all nodes in the representation of package Standard other than
-- nodes representing the contents of Standard.ASCII. Note that testing for