gnatbind.adb: If there are several ALI files specified and there is a main program...
authorVincent Celier <celier@adacore.com>
Wed, 26 Sep 2007 10:44:26 +0000 (12:44 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 26 Sep 2007 10:44:26 +0000 (12:44 +0200)
2007-09-26  Vincent Celier  <celier@adacore.com>

* gnatbind.adb: If there are several ALI files specified and there is
a main program to bind, the first ALI is expected to contain the main
subprogram and the names of the binder generated files will be derived
from the first ALI file name.
(Gnatbind): Fix insertion character in invocation of Error_Msg

From-SVN: r128793

gcc/ada/gnatbind.adb

index 7cc353d227bde3ee95548ea38833a0a73b6d6d6d..8a166991c5c00dbc1c74dcd44993998139885348 100644 (file)
@@ -64,6 +64,10 @@ procedure Gnatbind is
    Main_Lib_File : File_Name_Type;
    --  Current main library file
 
+   First_Main_Lib_File : File_Name_Type := No_File;
+   --  The first library file, that should be a main subprogram if neither -n
+   --  nor -z are used.
+
    Std_Lib_File : File_Name_Type;
    --  Standard library
 
@@ -593,6 +597,10 @@ begin
       while More_Lib_Files loop
          Main_Lib_File := Next_Main_Lib_File;
 
+         if First_Main_Lib_File = No_File then
+            First_Main_Lib_File := Main_Lib_File;
+         end if;
+
          if Verbose_Mode then
             if Check_Only then
                Write_Str ("Checking: ");
@@ -683,6 +691,15 @@ begin
 
       Set_Source_Table;
 
+      --  If there is main program to bind, set Main_Lib_File to the first
+      --  library file, and the name from which to derive the binder generate
+      --  file to the first ALI file.
+
+      if Bind_Main_Program then
+         Main_Lib_File := First_Main_Lib_File;
+         Set_Current_File_Name_Index (To => 1);
+      end if;
+
       --  Check that main library file is a suitable main program
 
       if Bind_Main_Program
@@ -690,7 +707,7 @@ begin
         and then not No_Main_Subprogram
       then
          Error_Msg_File_1 := Main_Lib_File;
-         Error_Msg ("% does not contain a unit that can be a main program");
+         Error_Msg ("{ does not contain a unit that can be a main program");
       end if;
 
       --  Perform consistency and correctness checks