From: pmderodat Date: Tue, 11 Dec 2018 11:10:07 +0000 (+0000) Subject: [Ada] Better error message from GNATprove on illegal switch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb25591e807995b609e59b0cb8bcde006edd82b2;p=thirdparty%2Fgcc.git [Ada] Better error message from GNATprove on illegal switch When a compilation switch is wrongly passed to GNATprove without the leading hyphen, this patch issues a clear error message instead of the obscure 'usage' message previously displayed. There is no impact on compilation. 2018-12-11 Yannick Moy gcc/ada/ * gnat1drv.adb (Gnat1drv): Issue specific error message in GNATprove mode when multiple file names on the command line. * osint.adb, osint.ads (Dump_Command_Line_Source_File_Names): New procedure to print file names on the command line. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266989 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ba91b12b95b1..003bea4501d1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-12-11 Yannick Moy + + * gnat1drv.adb (Gnat1drv): Issue specific error message in + GNATprove mode when multiple file names on the command line. + * osint.adb, osint.ads (Dump_Command_Line_Source_File_Names): + New procedure to print file names on the command line. + 2018-12-11 Javier Miranda * exp_aggr.adb (Convert_To_Assignments): When gnerating C, do diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index eab2fda1a00d..3c1bf360c252 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -1161,8 +1161,21 @@ begin -- gnat1 is invoked from gcc in the normal case. if Osint.Number_Of_Files /= 1 then - Usage; - Write_Eol; + + -- In GNATprove mode, gcc is not called, so we may end up with + -- switches wrongly interpreted as source file names when they are + -- written by mistake without a starting hyphen. Issue a specific + -- error message but do not print the internal 'usage' message. + + if GNATprove_Mode then + Write_Str ("one of the following is not a valid switch" + & " or source file name: "); + Osint.Dump_Command_Line_Source_File_Names; + else + Usage; + Write_Eol; + end if; + Osint.Fail ("you must provide one source file"); elsif Usage_Requested then diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index e7644b1fe5d7..58e493237470 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -787,6 +787,17 @@ package body Osint is end if; end Dir_In_Src_Search_Path; + ----------------------------------------- + -- Dump_Command_Line_Source_File_Names -- + ----------------------------------------- + + procedure Dump_Command_Line_Source_File_Names is + begin + for J in 1 .. Number_Of_Files loop + Write_Str (File_Names (J).all & " "); + end loop; + end Dump_Command_Line_Source_File_Names; + ---------------------------- -- Dump_Source_File_Names -- ---------------------------- diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads index 6c75b5214562..4be420ed75ec 100644 --- a/gcc/ada/osint.ads +++ b/gcc/ada/osint.ads @@ -508,6 +508,9 @@ package Osint is -- (i.e. Include_Dir_Default_Prefix). The text is sent to whatever Output -- is currently using (e.g. standard output or standard error). + procedure Dump_Command_Line_Source_File_Names; + -- Prints out the names of all source files on the command-line + ------------------------------------------- -- Representation of Library Information -- -------------------------------------------