summaryrefslogtreecommitdiff
path: root/gcc/ada/impunit.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-15 12:53:31 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-15 12:53:31 +0000
commit7bc11884cd3b21eec85cb6e36f13d0c53343e38f (patch)
tree0577e536fa3418edd38ae272ec6be69c6c097f3a /gcc/ada/impunit.adb
parent620b1003b7a794031cdc45602d4dcadc519f3363 (diff)
downloadgcc-7bc11884cd3b21eec85cb6e36f13d0c53343e38f.tar.gz
2009-07-15 Robert Dewar <dewar@adacore.com>
* gnat_rm.texi: Document s-ststop.ads * impunit.ad: (Map_Array): New table of alternative names (Get_Kind_Of_Unit): Return possible suggested alternative name * impunit.ads (Get_Kind_Of_Unit): Return possible suggested alternative name. * sem_ch10.adb (Analalyze_With_Clause): Add name of possible alternative unit if an implementation unit is with'ed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149685 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/impunit.adb')
-rw-r--r--gcc/ada/impunit.adb57
1 files changed, 56 insertions, 1 deletions
diff --git a/gcc/ada/impunit.adb b/gcc/ada/impunit.adb
index 4cf3e0c01a5..94112ff8ef5 100644
--- a/gcc/ada/impunit.adb
+++ b/gcc/ada/impunit.adb
@@ -24,6 +24,7 @@
------------------------------------------------------------------------------
with Atree; use Atree;
+with Errout; use Errout;
with Sinfo; use Sinfo;
with Fname.UF; use Fname.UF;
with Lib; use Lib;
@@ -471,6 +472,42 @@ package body Impunit is
"g-zspche", -- GNAT.Wide_Wide_Spelling_Checker
"g-zstspl"); -- GNAT.Wide_Wide_String_Split
+ -----------------------
+ -- Alternative Units --
+ -----------------------
+
+ -- For some implementation units, there is a unit in the GNAT library
+ -- that has identical functionality that is usable. If we have such a
+ -- case we record the appropriate Unit name in Error_Msg_String.
+
+ type Aunit_Record is record
+ Fname : String (1 .. 6);
+ Aname : String_Ptr;
+ end record;
+
+ -- Array of alternative unit names
+
+ Scasuti : aliased String := "GNAT.Case_Util";
+ Sos_lib : aliased String := "GNAT.OS_Lib";
+ Sregexp : aliased String := "GNAT.Regexp";
+ Sregpat : aliased String := "GNAT.Regpat";
+ Sstring : aliased String := "GNAT.Strings";
+ Sstusta : aliased String := "GNAT.Task_Stack_Usage";
+ Stasloc : aliased String := "GNAT.Task_Lock";
+ Sutf_32 : aliased String := "GNAT.UTF_32";
+
+ -- Array giving mapping
+
+ Map_Array : constant array (1 .. 8) of Aunit_Record := (
+ ("casuti", Scasuti'Access),
+ ("os_lib", Sos_lib'Access),
+ ("regexp", Sregexp'Access),
+ ("regpat", Sregpat'Access),
+ ("string", Sstring'Access),
+ ("stusta", Sstusta'Access),
+ ("tasloc", Stasloc'Access),
+ ("utf_32", Sutf_32'Access));
+
----------------------
-- Get_Kind_Of_Unit --
----------------------
@@ -479,6 +516,8 @@ package body Impunit is
Fname : constant File_Name_Type := Unit_File_Name (U);
begin
+ Error_Msg_Strlen := 0;
+
-- If length of file name is greater than 12, not predefined.
-- The value 12 here is an 8 char name with extension .ads.
@@ -559,7 +598,23 @@ package body Impunit is
return Ada_95_Unit;
end if;
- -- All tests failed, this is definitely an implementation unit
+ -- All tests failed, this is definitely an implementation unit. See if
+ -- we have an alternative name.
+
+ Get_Name_String (Fname);
+
+ if Name_Len = 12
+ and then Name_Buffer (1 .. 2) = "s-"
+ and then Name_Buffer (9 .. 12) = ".ads"
+ then
+ for J in Map_Array'Range loop
+ if Name_Buffer (3 .. 8) = Map_Array (J).Fname then
+ Error_Msg_Strlen := Map_Array (J).Aname'Length;
+ Error_Msg_String (1 .. Error_Msg_Strlen) :=
+ Map_Array (J).Aname.all;
+ end if;
+ end loop;
+ end if;
return Implementation_Unit;
end Get_Kind_Of_Unit;