This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Better error reporting for xgnatug


This patch adds better error reporting to xgnatug if one of the input
or output files cannot be opened.

Jeff, this should give you are more useful error message in your Ada
bootstrap failure.

2003-07-06  Florian Weimer  <fw@deneb.enyo.de>

	* xgnatug.adb: Better reporting of errors.

--- orig/gcc/ada/xgnatug.adb
+++ mod/gcc/ada/xgnatug.adb
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---            Copyright (C) 2002 Free Software Foundation, Inc.             --
+--            Copyright (C) 2002, 2003 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- --
@@ -1163,18 +1163,24 @@
 begin
    Initialize_Extensions;
 
-   Valid_Command_Line := Argument_Count in 3 .. 4;
+   if Argument_Count not in 3 .. 4 then
+      Usage;
+      Set_Exit_Status (Failure);
+      return;
+   else
+      Valid_Command_Line := True;
+   end if;
 
    --  First argument: Target.
 
-   if Valid_Command_Line then
-      begin
-         Target := Target_Type'Value (Argument (1));
-      exception
-         when Constraint_Error =>
-            Valid_Command_Line := False;
-      end;
-   end if;
+   begin
+      Target := Target_Type'Value (Argument (1));
+   exception
+      when Constraint_Error =>
+         Put_Line (Standard_Error, "error: invalid target '"
+                   & Argument (1) & ''');
+         Valid_Command_Line := False;
+   end;
 
    --  Second argument: Source_File.
 
@@ -1183,7 +1189,9 @@
          Source_File.Name := V (Argument (2));
          Open (Source_File.Data, In_File, Argument (2));
       exception
-         when Name_Error =>
+         when Name_Error | Use_Error =>
+            Put_Line (Standard_Error, "error: cannot open source file '"
+                      & Argument (2) & ''');
             Valid_Command_Line := False;
       end;
    end if;
@@ -1195,7 +1203,9 @@
          Dictionary_File.Name := V (Argument (3));
          Open (Dictionary_File.Data, In_File, Argument (3));
       exception
-         when Name_Error =>
+         when Name_Error | Use_Error =>
+            Put_Line (Standard_Error, "error: cannot open dictionary file '"
+                      & Argument (3) & ''');
             Valid_Command_Line := False;
       end;
    end if;
@@ -1222,12 +1232,15 @@
          Create (Output_File, Out_File, S (Output_File_Name));
       exception
          when Name_Error | Use_Error =>
+            Put_Line (Standard_Error, "error: cannot open output file '"
+                      & S (Output_File_Name) & ''');
             Valid_Command_Line := False;
       end;
    end if;
 
    if not Valid_Command_Line then
-      Usage;
+      Put_Line (Standard_Error, "For instructions, invoke 'xgnatug' "
+                & "without arguments.");
       Set_Exit_Status (Failure);
    else
       Read_Dictionary_File;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]