From 1a5d715a60307e8f70254c9c550b5e6916fde76e Mon Sep 17 00:00:00 2001 From: Vincent Celier Date: Wed, 26 Mar 2008 08:41:16 +0100 Subject: prj-dect.adb (Parse_Package_Declaration): When a package name is not known... 2008-03-26 Vincent Celier * prj-dect.adb (Parse_Package_Declaration): When a package name is not known, check if it may be a missspelling of a known package name. In not verbose, not mode, issue warnings only if the package name is a possible misspelling. In verbose mode, always issue a warning for a not known package name, plus a warning if the name is a misspelling of a known package name. * prj-part.adb (Post_Parse_Context_Clause): Modify so that only non limited withs or limited withs are parse during one call. (Parse_Single_Project): Post parse context clause in two passes: non limited withs before current project and limited withs after current project. * prj-proc.adb (Imported_Or_Extended_Project_From): Returns an extended project with the name With_Name, even if it is only extended indirectly. (Recursive_Process): Process projects in order: first single withs, then current project, then limited withs. * prj-tree.adb (Imported_Or_Extended_Project_Of): Returns an extended project with the name With_Name, even if it is only extended indirectly. From-SVN: r133573 --- gcc/ada/prj-dect.adb | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'gcc/ada/prj-dect.adb') diff --git a/gcc/ada/prj-dect.adb b/gcc/ada/prj-dect.adb index 24c312e..f9528d0 100644 --- a/gcc/ada/prj-dect.adb +++ b/gcc/ada/prj-dect.adb @@ -25,7 +25,8 @@ with Err_Vars; use Err_Vars; -with GNAT.Case_Util; use GNAT.Case_Util; +with GNAT.Case_Util; use GNAT.Case_Util; +with GNAT.Spelling_Checker; use GNAT.Spelling_Checker; with Opt; use Opt; with Prj.Attr; use Prj.Attr; @@ -36,8 +37,12 @@ with Prj.Tree; use Prj.Tree; with Snames; with Uintp; use Uintp; +with System.Strings; + package body Prj.Dect is + use System; + type Zone is (In_Project, In_Package, In_Case_Construction); -- Used to indicate if we are parsing a package (In_Package), -- a case construction (In_Case_Construction) or none of those two @@ -983,11 +988,44 @@ package body Prj.Dect is if Current_Package = Empty_Package then if not Quiet_Output then - Error_Msg ("?""" & - Get_Name_String - (Name_Of (Package_Declaration, In_Tree)) & - """ is not a known package name", - Token_Ptr); + declare + List : constant Strings.String_List := Package_Name_List; + Index : Natural; + Name : constant String := Get_Name_String (Token_Name); + + begin + -- Check for possible misspelling of a known package name + + Index := 0; + loop + if Index >= List'Last then + Index := 0; + exit; + end if; + + Index := Index + 1; + exit when + GNAT.Spelling_Checker.Is_Bad_Spelling_Of + (Name, List (Index).all); + end loop; + + -- Issue warning(s) in verbose mode or when a possible + -- misspelling has been found. + + if Verbose_Mode or else Index /= 0 then + Error_Msg ("?""" & + Get_Name_String + (Name_Of (Package_Declaration, In_Tree)) & + """ is not a known package name", + Token_Ptr); + end if; + + if Index /= 0 then + Error_Msg ("\?possible misspelling of """ & + List (Index).all & """", + Token_Ptr); + end if; + end; end if; -- Set the package declaration to "ignored" so that it is not -- cgit v1.1