As shown by this example, the recognition of misspelled aspects is
improved:
1. package UnrecogAs with Prelaborate is
|
>>> "Prelaborate" is not a valid aspect identifier
>>> possible misspelling of "Preelaborate"
2. type R is tagged null record;
3. end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-20 Robert Dewar <[email protected]>
* par-ch13.adb (Possible_Misspelled_Aspect): New function.
Index: par-ch13.adb
===================================================================
--- par-ch13.adb (revision 216469)
+++ par-ch13.adb (working copy)
@@ -45,6 +45,26 @@
Scan_State : Saved_Scan_State;
Result : Boolean;
+ function Possible_Misspelled_Aspect return Boolean;
+ -- Returns True, if Token_Name is a misspelling of some aspect name
+
+ --------------------------------
+ -- Possible_Misspelled_Aspect --
+ --------------------------------
+
+ function Possible_Misspelled_Aspect return Boolean is
+ begin
+ for J in Aspect_Id_Exclude_No_Aspect loop
+ if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
+ return True;
+ end if;
+ end loop;
+
+ return False;
+ end Possible_Misspelled_Aspect;
+
+ -- Start of processing for Aspect_Specifications_Present
+
begin
-- Definitely must have WITH to consider aspect specs to be present
@@ -74,17 +94,20 @@
if Token /= Tok_Identifier then
Result := False;
- -- This is where we pay attention to the Strict mode. Normally when we
- -- are in Ada 2012 mode, Strict is False, and we consider that we have
- -- an aspect specification if the identifier is an aspect name (even if
- -- not followed by =>) or the identifier is not an aspect name but is
- -- followed by =>, by a comma, or by a semicolon. The last two cases
- -- correspond to (misspelled) Boolean aspects with a defaulted value of
- -- True. P_Aspect_Specifications will generate messages if the aspect
+ -- This is where we pay attention to the Strict mode. Normally when
+ -- we are in Ada 2012 mode, Strict is False, and we consider that we
+ -- have an aspect specification if the identifier is an aspect name
+ -- or a likely misspelling of one (even if not followed by =>) or
+ -- the identifier is not an aspect name but is followed by =>, by
+ -- a comma, or by a semicolon. The last two cases correspond to
+ -- (misspelled) Boolean aspects with a defaulted value of True.
+ -- P_Aspect_Specifications will generate messages if the aspect
-- specification is ill-formed.
elsif not Strict then
- if Get_Aspect_Id (Token_Name) /= No_Aspect then
+ if Get_Aspect_Id (Token_Name) /= No_Aspect
+ or else Possible_Misspelled_Aspect
+ then
Result := True;
else
Scan; -- past identifier