aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/par.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-01-27 17:39:57 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2014-01-27 17:39:57 +0100
commit8fdafe44be001fa59172d7a28626d4babdc24b7b (patch)
tree691222cccf636cf338d10501185fedb34354d5fb /gcc/ada/par.adb
parentb3a699930b7b61d37753e8714929cd2d9c1fb6d8 (diff)
[multiple changes]
2014-01-27 Thomas Quinot <quinot@adacore.com> * exp_ch7.adb: Minor reformatting. 2014-01-27 Robert Dewar <dewar@adacore.com> * opt.adb (SPARK_Mode): Default for library units is None rather than Off. * opt.ads: Remove AUTO from SPARK_Mode_Type SPARK_Mode_Type is no longer ordered. * sem_prag.adb (Analyze_Pragma, case SPARK_Mode): Remove AUTO possibility. * snames.ads-tmpl (Name_Auto): Removed, no longer used. 2014-01-27 Robert Dewar <dewar@adacore.com> * par-ch5.adb (P_Sequence_Of_Statements): Make entry in Suspicious_Labels table if we have identifier; followed by loop or block. * par-endh.adb (Evaluate_End_Entry): Search Suspicious_Labels table. * par.adb (Suspicious_Labels): New table. 2014-01-27 Robert Dewar <dewar@adacore.com> * exp_aggr.adb (Check_Bounds): Reason is range check, not length check. 2014-01-27 Yannick Moy <moy@adacore.com> * get_spark_xrefs.adb (Get_SPARK_Xrefs): Accept new type 'c' for reference. * lib-xref-spark_specific.adb (Is_Global_Constant): Remove useless function now. (Add_SPARK_Xrefs): Include references to constants. * spark_xrefs.ads Document new character 'c' for references to constants. 2014-01-27 Thomas Quinot <quinot@adacore.com> * exp_smem.adb (Add_Write_After): For a function call, insert write as an after action in a transient scope. From-SVN: r207140
Diffstat (limited to 'gcc/ada/par.adb')
-rw-r--r--gcc/ada/par.adb60
1 files changed, 60 insertions, 0 deletions
diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb
index 6788692864e..7e69166ddc0 100644
--- a/gcc/ada/par.adb
+++ b/gcc/ada/par.adb
@@ -535,6 +535,66 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
Table_Increment => 100,
Table_Name => "Scope");
+ ------------------------------------------
+ -- Table for Handling Suspicious Labels --
+ ------------------------------------------
+
+ -- This is a special data structure which is used to deal very spefifically
+ -- with the following error case
+
+ -- label;
+ -- loop
+ -- ...
+ -- end loop label;
+
+ -- Similar cases apply to FOR, WHILE, DECLARE, or BEGIN
+
+ -- In each case the opening line looks like a procedure call because of
+ -- the semicolon. And the end line looks illegal because of an unexpected
+ -- label. If we did nothing special, we would just diagnose the label on
+ -- the end as unexpected. But that does not help point to the real error
+ -- which is that the semicolon after label should be a colon.
+
+ -- To deal with this, we build an entry in the Suspicious_Labels table
+ -- whenever we encounter an identifier followed by a semicolon, followed
+ -- by one of LOOP, FOR, WHILE, DECLARE, BEGIN. Then this entry is used to
+ -- issue the right message when we hit the END that confirms that this was
+ -- a bad label.
+
+ type Suspicious_Label_Entry is record
+ Proc_Call : Node_Id;
+ -- Node for the procedure call statement built for the label; construct
+
+ Semicolon_Loc : Source_Ptr;
+ -- Location of the possibly wrong semicolon
+
+ Start_Token : Source_Ptr;
+ -- Source location of the LOOP, FOR, WHILE, DECLARE, BEGIN token
+ end record;
+
+ package Suspicious_Labels is new Table.Table (
+ Table_Component_Type => Suspicious_Label_Entry,
+ Table_Index_Type => Int,
+ Table_Low_Bound => 1,
+ Table_Initial => 50,
+ Table_Increment => 100,
+ Table_Name => "Suspicious_Labels");
+
+ -- Now when we are about to issue a message complaining about an END label
+ -- that should not be there because it appears to end a construct that has
+ -- no label, we first search the suspicious labels table entry, using the
+ -- source location stored in the scope table as a key. If we find a match,
+ -- then we check that the label on the end matches the name in the call,
+ -- and if so, we issue a message saying the semicolon should be a colon.
+
+ -- Quite a bit of work, but really helpful in the case where it helps, and
+ -- the need for this is based on actual experience with tracking down this
+ -- kind of error (the eye often easily mistakes semicolon for colon!)
+
+ -- Note: we actually have enough information to patch up the tree, but
+ -- this may not be worth the effort! Also we could deal with the same
+ -- situation for EXIT with a label, but for now don't bother with that!
+
---------------------------------
-- Parsing Routines by Chapter --
---------------------------------