aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinput-l.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sinput-l.adb')
-rw-r--r--gcc/ada/sinput-l.adb44
1 files changed, 24 insertions, 20 deletions
diff --git a/gcc/ada/sinput-l.adb b/gcc/ada/sinput-l.adb
index 68da307..7a2917f 100644
--- a/gcc/ada/sinput-l.adb
+++ b/gcc/ada/sinput-l.adb
@@ -30,7 +30,7 @@ with Debug; use Debug;
with Einfo; use Einfo;
with Errout; use Errout;
with Namet; use Namet;
-with Opt;
+with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Prep; use Prep;
@@ -78,9 +78,8 @@ package body Sinput.L is
-- Used to initialize the preprocessor.
function Load_File
- (N : File_Name_Type;
- T : Osint.File_Type)
- return Source_File_Index;
+ (N : File_Name_Type;
+ T : Osint.File_Type) return Source_File_Index;
-- Load a source file, a configuration pragmas file or a definition file
-- Coding also allows preprocessing file, but not a library file ???
@@ -265,8 +264,7 @@ package body Sinput.L is
----------------------
function Load_Config_File
- (N : File_Name_Type)
- return Source_File_Index
+ (N : File_Name_Type) return Source_File_Index
is
begin
return Load_File (N, Osint.Config);
@@ -277,8 +275,7 @@ package body Sinput.L is
--------------------------
function Load_Definition_File
- (N : File_Name_Type)
- return Source_File_Index
+ (N : File_Name_Type) return Source_File_Index
is
begin
return Load_File (N, Osint.Definition);
@@ -289,9 +286,8 @@ package body Sinput.L is
---------------
function Load_File
- (N : File_Name_Type;
- T : Osint.File_Type)
- return Source_File_Index
+ (N : File_Name_Type;
+ T : Osint.File_Type) return Source_File_Index
is
Src : Source_Buffer_Ptr;
X : Source_File_Index;
@@ -301,11 +297,21 @@ package body Sinput.L is
Preprocessing_Needed : Boolean := False;
begin
- for J in 1 .. Source_File.Last loop
- if Source_File.Table (J).File_Name = N then
- return J;
- end if;
- end loop;
+ -- If already there, don't need to reload file. An exception occurs
+ -- in multiple unit per file mode. It would be nice in this case to
+ -- share the same source file for each unit, but this leads to many
+ -- difficulties with assumptions (e.g. in the body of lib), that a
+ -- unit can be found by locating its source file index. Since we do
+ -- not expect much use of this mode, it's no big deal to waste a bit
+ -- of space and time by reading and storing the source multiple times.
+
+ if Multiple_Unit_Index = 0 then
+ for J in 1 .. Source_File.Last loop
+ if Source_File.Table (J).File_Name = N then
+ return J;
+ end if;
+ end loop;
+ end if;
-- Here we must build a new entry in the file table
@@ -584,8 +590,7 @@ package body Sinput.L is
----------------------------------
function Load_Preprocessing_Data_File
- (N : File_Name_Type)
- return Source_File_Index
+ (N : File_Name_Type) return Source_File_Index
is
begin
return Load_File (N, Osint.Preprocessing_Data);
@@ -596,8 +601,7 @@ package body Sinput.L is
----------------------
function Load_Source_File
- (N : File_Name_Type)
- return Source_File_Index
+ (N : File_Name_Type) return Source_File_Index
is
begin
return Load_File (N, Osint.Source);