8sa1-gcc/gcc/ada/sinput-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

207 lines
7.5 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S I N P U T . C --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-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 Ada.Unchecked_Conversion;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Namet; use Namet;
with Opt; use Opt;
with System; use System;
package body Sinput.C is
---------------
-- Load_File --
---------------
function Load_File (Path : String) return Source_File_Index is
Src : Source_Buffer_Ptr;
X : Source_File_Index;
Lo : Source_Ptr;
Hi : Source_Ptr;
Source_File_FD : File_Descriptor;
-- The file descriptor for the current source file. A negative value
-- indicates failure to open the specified source file.
Len : Integer;
-- Length of file. Assume no more than 2 gigabytes of source!
Actual_Len : Integer;
Path_Id : Name_Id;
File_Id : Name_Id;
begin
if Path = "" then
return No_Source_File;
end if;
Source_File.Increment_Last;
X := Source_File.Last;
if X = Source_File.First then
Lo := First_Source_Ptr;
else
Lo := Source_File.Table (X - 1).Source_Last + 1;
end if;
Name_Len := Path'Length;
Name_Buffer (1 .. Name_Len) := Path;
Path_Id := Name_Find;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
-- Open the source FD, note that we open in binary mode, because as
-- documented in the spec, the caller is expected to handle either
-- DOS or Unix mode files, and there is no point in wasting time on
-- text translation when it is not required.
Source_File_FD := Open_Read (Name_Buffer'Address, Binary);
if Source_File_FD = Invalid_FD then
Source_File.Decrement_Last;
return No_Source_File;
end if;
Len := Integer (File_Length (Source_File_FD));
-- Set Hi so that length is one more than the physical length,
-- allowing for the extra EOF character at the end of the buffer
Hi := Lo + Source_Ptr (Len);
-- Do the actual read operation
declare
subtype Actual_Source_Buffer is Source_Buffer (Lo .. Hi);
-- Physical buffer allocated
type Actual_Source_Ptr is access Actual_Source_Buffer;
-- This is the pointer type for the physical buffer allocated
Actual_Ptr : constant Actual_Source_Ptr := new Actual_Source_Buffer;
-- And this is the actual physical buffer
begin
-- Allocate source buffer, allowing extra character at end for EOF
-- Some systems (e.g. VMS) have file types that require one
-- read per line, so read until we get the Len bytes or until
-- there are no more characters.
Hi := Lo;
loop
Actual_Len := Read (Source_File_FD, Actual_Ptr (Hi)'Address, Len);
Hi := Hi + Source_Ptr (Actual_Len);
exit when Actual_Len = Len or Actual_Len <= 0;
end loop;
Actual_Ptr (Hi) := EOF;
-- Now we need to work out the proper virtual origin pointer to
-- return. This is exactly Actual_Ptr (0)'Address, but we have
-- to be careful to suppress checks to compute this address.
declare
pragma Suppress (All_Checks);
pragma Warnings (Off);
-- The following unchecked conversion is aliased safe, since it
-- is not used to create improperly aliased pointer values.
function To_Source_Buffer_Ptr is new
Ada.Unchecked_Conversion (Address, Source_Buffer_Ptr);
pragma Warnings (On);
begin
Src := To_Source_Buffer_Ptr (Actual_Ptr (0)'Address);
end;
end;
-- Read is complete, close the file and we are done (no need to test
-- status from close, since we have successfully read the file!)
Close (Source_File_FD);
-- Get the file name, without path information
declare
Index : Positive := Path'Last;
begin
while Index > Path'First loop
exit when Path (Index - 1) = '/';
exit when Path (Index - 1) = Directory_Separator;
Index := Index - 1;
end loop;
Name_Len := Path'Last - Index + 1;
Name_Buffer (1 .. Name_Len) := Path (Index .. Path'Last);
File_Id := Name_Find;
end;
declare
S : Source_File_Record renames Source_File.Table (X);
begin
S := (Debug_Source_Name => File_Id,
File_Name => File_Id,
File_Type => Config,
First_Mapped_Line => No_Line_Number,
Full_Debug_Name => Path_Id,
Full_File_Name => Path_Id,
Full_Ref_Name => Path_Id,
Identifier_Casing => Unknown,
Inlined_Body => False,
Instantiation => No_Location,
Keyword_Casing => Unknown,
Last_Source_Line => 1,
License => Unknown,
Lines_Table => null,
Lines_Table_Max => 1,
Logical_Lines_Table => null,
Num_SRef_Pragmas => 0,
Reference_Name => File_Id,
Sloc_Adjust => 0,
Source_Checksum => 0,
Source_First => Lo,
Source_Last => Hi,
Source_Text => Src,
Template => No_Source_File,
Time_Stamp => Empty_Time_Stamp);
Alloc_Line_Tables (S, Opt.Table_Factor * Alloc.Lines_Initial);
S.Lines_Table (1) := Lo;
end;
Set_Source_File_Index_Table (X);
return X;
end Load_File;
end Sinput.C;