8sa1-gcc/gcc/ada/osint-c.adb
Arnaud Charlet 6b6fcd3ead [multiple changes]
2004-04-01  Robert Dewar  <dewar@gnat.com>

	* checks.adb: Minor reformatting throughout
	Note that prev checkin added RM reference to alignment warning

2004-04-01  Ed Schonberg  <schonberg@gnat.com>

	* exp_aggr.adb (Get_Component_Val): Treat a string literal as
	non-static when building aggregate for bit-packed array.

	* exp_ch4.adb (Expand_N_Slice): If a packed slice is an actual of a
	function call that is itself the actual in a procedure call, build
	temporary for it.

	* exp_pakd.adb (Expand_Bit_Packed_Element_Set): If right-hand side is
	a string literal, create a temporary for it, constant folding only
	handles scalars here.

2004-04-01  Vincent Celier  <celier@gnat.com>

	* ali-util.adb (Post_Scan, Error_Msg, Error_Msg_S, Error_Msg_SC,
	Error_Msg_SP): New empty procedures to instantiate the Scanner.
	(Style, Scanner): Instantiations of Styleg and Scng to be able to scan
	tokens.
	(Accumulate_Checksum, Initialize_Checksum): Remove procedures.
	(Get_File_Checksum): Use the instantiated scanner to scan all the tokens
	and get the checksum.

	* make.adb (Gnatmake): Do not insert into Q the Main_Source if it is
	already in the Q.
	Increase the Marking_Label at the end of the Multiple_Main_Loop,
	instead of at the beginning.

	* osint.adb (Lib_File_Name): Use Multi_Unit_Index_Character, not '~'
	directly.
	(Osint package elaboration): Change Multi_Unit_Index_Character to '$' if
	on VMS.

	* osint.ads (Multi_Unit_Index_Character): New Character global variable

	* osint-c.adb (Set_Library_Info_Name): Use Multi_Unit_Index_Character,
	not '~' directly.

	* par.adb: Remove test on file name to detect language defined units.
	Add test on unit name, after parsing, to detect language defined units
	that are not compiled with -gnatg (except System.RPC and its children)

	* par-ch10.adb (P_Compilation_Unit): In multi-unit sources, scan the
	following units without style checking.

	* switch-c.adb: Change -gnatC to -gnateI

	* usage.adb: Document new switch -gnateInnn

	* scng.adb (Accumulate_Token_Checksum): New procedure
	(Scan): Call Accumulate_Token_Checksum after each identifier, reserved
	word or literal number.
	(Scan.Nlit.Scan_Integer): Do not accumulate internal '_' in litteral
	numbers.

2004-04-01  Thomas Quinot  <quinot@act-europe.fr>

	* a-tasatt.adb,
	g-comlin.adb, sinput-c.adb, s-secsta.adb, s-tpobop.adb,
	switch-m.adb, 56taprop.adb, 5ginterr.adb, 5gmastop.adb,
	5staprop.adb, 5vinterr.adb, 5vtaprop.adb, 5vtpopde.adb,
	5vtpopde.adb: Add missing 'constant' keywords.

2004-04-01  Javier Miranda  <miranda@gnat.com>

	* par-ch4.adb: (P_Allocator): Code cleanup

	* sem_ch3.adb (Access_Definition): Properly set the null-excluding
	attribute.

	* sinfo.ads: Complete documentation of previous change

2004-04-01  GNAT Script  <nobody@gnat.com>

	* Make-lang.in: Makefile automatically updated

2004-04-01  Pascal Obry  <obry@gnat.com>

	* gnatlink.adb (Process_Binder_File): Remove duplicate linker options
	only on VMS.  This special handling was done because an old GNU/ld bug
	on Windows which has been fixed.

From-SVN: r80290
2004-04-01 12:04:40 +02:00

432 lines
13 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O S I N T - C --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2004 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- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Hostparm;
with Namet; use Namet;
with Opt; use Opt;
with Tree_IO; use Tree_IO;
package body Osint.C is
Output_Object_File_Name : String_Ptr;
-- Argument of -o compiler option, if given. This is needed to
-- verify consistency with the ALI file name.
procedure Adjust_OS_Resource_Limits;
pragma Import (C, Adjust_OS_Resource_Limits,
"__gnat_adjust_os_resource_limits");
-- Procedure to make system specific adjustments to make GNAT
-- run better.
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type;
-- Common processing for Creat_Repinfo_File and Create_Debug_File.
-- Src is the file name used to create the required output file and
-- Suffix is the desired suffic (dg/rep for debug/repinfo file).
procedure Set_Library_Info_Name;
-- Sets a default ali file name from the main compiler source name.
-- This is used by Create_Output_Library_Info, and by the version of
-- Read_Library_Info that takes a default file name. The name is in
-- Name_Buffer (with length in Name_Len) on return from the call
----------------------
-- Close_Debug_File --
----------------------
procedure Close_Debug_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing expanded source file ",
Get_Name_String (Output_File_Name));
end if;
end Close_Debug_File;
-------------------------------
-- Close_Output_Library_Info --
-------------------------------
procedure Close_Output_Library_Info is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing ALI file ",
Get_Name_String (Output_File_Name));
end if;
end Close_Output_Library_Info;
------------------------
-- Close_Repinfo_File --
------------------------
procedure Close_Repinfo_File is
Status : Boolean;
begin
Close (Output_FD, Status);
if not Status then
Fail
("error while closing representation info file ",
Get_Name_String (Output_File_Name));
end if;
end Close_Repinfo_File;
---------------------------
-- Create_Auxiliary_File --
---------------------------
function Create_Auxiliary_File
(Src : File_Name_Type;
Suffix : String) return File_Name_Type
is
Result : File_Name_Type;
begin
Get_Name_String (Src);
if Hostparm.OpenVMS then
Name_Buffer (Name_Len + 1) := '_';
else
Name_Buffer (Name_Len + 1) := '.';
end if;
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
if Output_Object_File_Name /= null then
for Index in reverse Output_Object_File_Name'Range loop
if Output_Object_File_Name (Index) = Directory_Separator then
declare
File_Name : constant String := Name_Buffer (1 .. Name_Len);
begin
Name_Len := Index - Output_Object_File_Name'First + 1;
Name_Buffer (1 .. Name_Len) :=
Output_Object_File_Name
(Output_Object_File_Name'First .. Index);
Name_Buffer (Name_Len + 1 .. Name_Len + File_Name'Length) :=
File_Name;
Name_Len := Name_Len + File_Name'Length;
end;
exit;
end if;
end loop;
end if;
Result := Name_Find;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
Create_File_And_Check (Output_FD, Text);
return Result;
end Create_Auxiliary_File;
-----------------------
-- Create_Debug_File --
-----------------------
function Create_Debug_File (Src : File_Name_Type) return File_Name_Type is
begin
return Create_Auxiliary_File (Src, "dg");
end Create_Debug_File;
--------------------------------
-- Create_Output_Library_Info --
--------------------------------
procedure Create_Output_Library_Info is
begin
Set_Library_Info_Name;
Create_File_And_Check (Output_FD, Text);
end Create_Output_Library_Info;
--------------------------
-- Creat_Repinfo_File --
--------------------------
procedure Creat_Repinfo_File (Src : File_Name_Type) is
S : constant File_Name_Type := Create_Auxiliary_File (Src, "rep");
pragma Warnings (Off, S);
begin
return;
end Creat_Repinfo_File;
---------------------------
-- Debug_File_Eol_Length --
---------------------------
function Debug_File_Eol_Length return Nat is
begin
-- There has to be a cleaner way to do this! ???
if Directory_Separator = '/' then
return 1;
else
return 2;
end if;
end Debug_File_Eol_Length;
-----------------------
-- More_Source_Files --
-----------------------
function More_Source_Files return Boolean renames More_Files;
----------------------
-- Next_Main_Source --
----------------------
function Next_Main_Source return File_Name_Type renames Next_Main_File;
-----------------------
-- Read_Library_Info --
-----------------------
-- Version with default file name
procedure Read_Library_Info
(Name : out File_Name_Type;
Text : out Text_Buffer_Ptr)
is
begin
Set_Library_Info_Name;
Name := Name_Find;
Text := Read_Library_Info (Name, Fatal_Err => False);
end Read_Library_Info;
---------------------------
-- Set_Library_Info_Name --
---------------------------
procedure Set_Library_Info_Name is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- Find last dot since we replace the existing extension by .ali. The
-- initialization to Name_Len + 1 provides for simply adding the .ali
-- extension if the source file name has no extension.
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Make sure that the output file name matches the source file name.
-- To compare them, remove file name directories and extensions.
if Output_Object_File_Name /= null then
-- Make sure there is a dot at Dot_Index. This may not be the case
-- if the source file name has no extension.
Name_Buffer (Dot_Index) := '.';
-- If we are in multiple unit per file mode, then add ~nnn
-- extension to the name before doing the comparison.
if Multiple_Unit_Index /= 0 then
declare
Exten : constant String := Name_Buffer (Dot_Index .. Name_Len);
begin
Name_Len := Dot_Index - 1;
Add_Char_To_Name_Buffer (Multi_Unit_Index_Character);
Add_Nat_To_Name_Buffer (Multiple_Unit_Index);
Dot_Index := Name_Len + 1;
Add_Str_To_Name_Buffer (Exten);
end;
end if;
-- Remove extension preparing to replace it
declare
Name : constant String := Name_Buffer (1 .. Dot_Index);
Len : constant Natural := Dot_Index;
begin
Name_Buffer (1 .. Output_Object_File_Name'Length) :=
Output_Object_File_Name.all;
Dot_Index := 0;
for J in reverse Output_Object_File_Name'Range loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Dot_Index should be zero now (we check for extension elsewhere)
pragma Assert (Dot_Index /= 0);
-- Check name of object file is what we expect
if Name /= Name_Buffer (Dot_Index - Len + 1 .. Dot_Index) then
Fail ("incorrect object file name");
end if;
end;
end if;
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1 .. Dot_Index + 3) := ALI_Suffix.all;
Name_Buffer (Dot_Index + 4) := ASCII.NUL;
Name_Len := Dot_Index + 3;
end Set_Library_Info_Name;
---------------------------------
-- Set_Output_Object_File_Name --
---------------------------------
procedure Set_Output_Object_File_Name (Name : String) is
Ext : constant String := Object_Suffix;
NL : constant Natural := Name'Length;
EL : constant Natural := Ext'Length;
begin
-- Make sure that the object file has the expected extension.
if NL <= EL
or else
(Name (NL - EL + Name'First .. Name'Last) /= Ext
and then Name (NL - 2 + Name'First .. Name'Last) /= ".o")
then
Fail ("incorrect object file extension");
end if;
Output_Object_File_Name := new String'(Name);
end Set_Output_Object_File_Name;
----------------
-- Tree_Close --
----------------
procedure Tree_Close is
Status : Boolean;
begin
Tree_Write_Terminate;
Close (Output_FD, Status);
if not Status then
Fail
("error while closing tree file ",
Get_Name_String (Output_File_Name));
end if;
end Tree_Close;
-----------------
-- Tree_Create --
-----------------
procedure Tree_Create is
Dot_Index : Natural;
begin
Get_Name_String (Current_Main);
-- If an object file has been specified, then the ALI file
-- will be in the same directory as the object file;
-- so, we put the tree file in this same directory,
-- even though no object file needs to be generated.
if Output_Object_File_Name /= null then
Name_Len := Output_Object_File_Name'Length;
Name_Buffer (1 .. Name_Len) := Output_Object_File_Name.all;
end if;
Dot_Index := Name_Len + 1;
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Dot_Index := J;
exit;
end if;
end loop;
-- Should be impossible to not have an extension
pragma Assert (Dot_Index /= 0);
-- Change exctension to adt
Name_Buffer (Dot_Index) := '.';
Name_Buffer (Dot_Index + 1) := 'a';
Name_Buffer (Dot_Index + 2) := 'd';
Name_Buffer (Dot_Index + 3) := 't';
Name_Buffer (Dot_Index + 4) := ASCII.NUL;
Name_Len := Dot_Index + 3;
Create_File_And_Check (Output_FD, Binary);
Tree_Write_Initialize (Output_FD);
end Tree_Create;
-----------------------
-- Write_Debug_Info --
-----------------------
procedure Write_Debug_Info (Info : String) renames Write_Info;
------------------------
-- Write_Library_Info --
------------------------
procedure Write_Library_Info (Info : String) renames Write_Info;
------------------------
-- Write_Repinfo_Line --
------------------------
procedure Write_Repinfo_Line (Info : String) renames Write_Info;
begin
Adjust_OS_Resource_Limits;
Opt.Creat_Repinfo_File_Access := Creat_Repinfo_File'Access;
Opt.Write_Repinfo_Line_Access := Write_Repinfo_Line'Access;
Opt.Close_Repinfo_File_Access := Close_Repinfo_File'Access;
Set_Program (Compiler);
end Osint.C;