gnat_rm.texi: Document s-ststop.ads

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.

From-SVN: r149685
This commit is contained in:
Robert Dewar 2009-07-15 12:53:31 +00:00 committed by Arnaud Charlet
parent 4cd029c79b
commit 3eb532e6aa
5 changed files with 102 additions and 11 deletions

View File

@ -1,3 +1,16 @@
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.
2009-07-15 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Minor updates.

View File

@ -409,6 +409,7 @@ The GNAT Library
* System.Pool_Local (s-pooloc.ads)::
* System.Restrictions (s-restri.ads)::
* System.Rident (s-rident.ads)::
* System.Strings.Stream_Ops (s-ststop.ads)::
* System.Task_Info (s-tasinf.ads)::
* System.Wch_Cnv (s-wchcnv.ads)::
* System.Wch_Con (s-wchcon.ads)::
@ -13597,6 +13598,7 @@ of GNAT, and will generate a warning message.
* System.Pool_Local (s-pooloc.ads)::
* System.Restrictions (s-restri.ads)::
* System.Rident (s-rident.ads)::
* System.Strings.Stream_Ops (s-ststop.ads)::
* System.Task_Info (s-tasinf.ads)::
* System.Wch_Cnv (s-wchcnv.ads)::
* System.Wch_Con (s-wchcon.ads)::
@ -14939,6 +14941,18 @@ It is not normally necessary to @code{with} this generic package
since the necessary instantiation is included in
package System.Restrictions.
@node System.Strings.Stream_Ops (s-ststop.ads)
@section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
@cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
@cindex Stream operations
@cindex String stream operations
@noindent
This package provides a set of stream subprograms for standard string types.
It is intended primarily to support implicit use of such subprograms when
stream attributes are applied to string types, but the subprograms in this
package can be used directly by application programs.
@node System.Task_Info (s-tasinf.ads)
@section @code{System.Task_Info} (@file{s-tasinf.ads})
@cindex @code{System.Task_Info} (@file{s-tasinf.ads})

View File

@ -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;

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2007, Free Software Foundation, Inc. --
-- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -55,7 +55,11 @@ package Impunit is
function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit;
-- Given the unit number of a unit, this function determines the type
-- of the unit, as defined above.
-- of the unit, as defined above. If the result is Implementation_Unit,
-- then the name of a possible atlernative equivalent unit is placed in
-- Error_Msg_String/Slen on return. If there is no alternative name, or
-- if the result is not Implementation_Unit, then Error_Msg_Slen is zero
-- on return, indicating that no alternative name was found.
function Is_Known_Unit (Nam : Node_Id) return Boolean;
-- Nam is the possible name of a child unit, represented as a selected

View File

@ -2334,12 +2334,10 @@ package body Sem_Ch10 is
end if;
-- Check for inappropriate with of internal implementation unit if we
-- are currently compiling the main unit and the main unit is itself
-- not an internal unit. We do not issue this message for implicit
-- with's generated by the compiler itself.
-- are not compiling an internal unit. We do not issue this message
-- for implicit with's generated by the compiler itself.
if Implementation_Unit_Warnings
and then Current_Sem_Unit = Main_Unit
and then not Intunit
and then not Implicit_With (N)
then
@ -2350,10 +2348,17 @@ package body Sem_Ch10 is
begin
if U_Kind = Implementation_Unit then
Error_Msg_F ("& is an internal 'G'N'A'T unit?", Name (N));
Error_Msg_F
("\use of this unit is non-portable " &
"and version-dependent?",
Name (N));
-- Add alternative name if available, otherwise issue a
-- general warning message.
if Error_Msg_Strlen /= 0 then
Error_Msg_F ("\use ""~"" instead", Name (N));
else
Error_Msg_F
("\use of this unit is non-portable " &
"and version-dependent?", Name (N));
end if;
elsif U_Kind = Ada_05_Unit
and then Ada_Version < Ada_05