Patchwork [Ada] Change of error message in gnatbind

login
register
mail settings
Submitter Arnaud Charlet
Date Oct. 5, 2010, 10:18 a.m.
Message ID <20101005101843.GA19894@adacore.com>
Download mbox | patch
Permalink /patch/66812/
State New
Headers show

Comments

Arnaud Charlet - Oct. 5, 2010, 10:18 a.m.
The message reported by gnatbind when the main unit cannot be a main
program is modified from:
  error: "main.ali" does not contain a unit that can be a main program
to:
  main.adb:1: Main cannot be used as a main program

The test for this is to invoke gnatbind on an ALI file for a library
procedure with parameters.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-05  Vincent Celier  <celier@adacore.com>

	* gnatbind.adb: If the main library file is not for a suitable main
	program, change the error message.

Patch

Index: gnatbind.adb
===================================================================
--- gnatbind.adb	(revision 164906)
+++ gnatbind.adb	(working copy)
@@ -789,8 +789,20 @@  begin
         and then ALIs.Table (ALIs.First).Main_Program = None
         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");
+         Get_Name_String
+           (Units.Table (ALIs.Table (ALIs.First).First_Unit).Uname);
+
+         declare
+            Unit_Name : String := Name_Buffer (1 .. Name_Len - 2);
+         begin
+            To_Mixed (Unit_Name);
+            Get_Name_String (ALIs.Table (ALIs.First).Sfile);
+            Add_Str_To_Name_Buffer (":1: ");
+            Add_Str_To_Name_Buffer (Unit_Name);
+            Add_Str_To_Name_Buffer (" cannot be used as a main program");
+            Write_Line (Name_Buffer (1 .. Name_Len));
+            Errors_Detected := Errors_Detected + 1;
+         end;
       end if;
 
       --  Perform consistency and correctness checks