From 2361fe47fa6bdb23f0b801ca646bf6c5983de5f8 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 4 Mar 2020 18:36:35 +0100 Subject: Warn on unexpected options for command '-a'. Fix #1066 --- src/ghdldrv/ghdlcomp.adb | 2 ++ src/ghdldrv/ghdldrv.adb | 3 +++ src/ghdldrv/ghdllocal.adb | 14 ++++++++++++++ src/ghdldrv/ghdllocal.ads | 4 ++++ 4 files changed, 23 insertions(+) (limited to 'src/ghdldrv') diff --git a/src/ghdldrv/ghdlcomp.adb b/src/ghdldrv/ghdlcomp.adb index 5a5ae3536..c0915af98 100644 --- a/src/ghdldrv/ghdlcomp.adb +++ b/src/ghdldrv/ghdlcomp.adb @@ -444,6 +444,8 @@ package body Ghdlcomp is raise Compilation_Error; end if; + Expect_Filenames (Args); + Hooks.Compile_Init.all (True); -- Parse all files. diff --git a/src/ghdldrv/ghdldrv.adb b/src/ghdldrv/ghdldrv.adb index 4d4ebfa61..c382f22bf 100644 --- a/src/ghdldrv/ghdldrv.adb +++ b/src/ghdldrv/ghdldrv.adb @@ -907,6 +907,9 @@ package body Ghdldrv is Error ("no file to analyze"); raise Option_Error; end if; + + Expect_Filenames (Args); + Setup_Compiler (False); for I in Args'Range loop diff --git a/src/ghdldrv/ghdllocal.adb b/src/ghdldrv/ghdllocal.adb index 40f2eb984..3baea8889 100644 --- a/src/ghdldrv/ghdllocal.adb +++ b/src/ghdldrv/ghdllocal.adb @@ -1707,6 +1707,20 @@ package body Ghdllocal is end if; end Extract_Elab_Unit; + procedure Expect_Filenames (Args : Argument_List) + is + use Errorout; + begin + for I in Args'Range loop + if Args (I)(Args (I)'First) = '-' then + Warning_Msg_Option + (Warnid_Unexpected_Option, + "no option expected after files, use ./" & Args (I).all); + exit; + end if; + end loop; + end Expect_Filenames; + -- Command Elab_Order. type Command_Elab_Order is new Command_Lib with null record; function Decode_Command (Cmd : Command_Elab_Order; Name : String) diff --git a/src/ghdldrv/ghdllocal.ads b/src/ghdldrv/ghdllocal.ads index 042c51d87..230ddd7f5 100644 --- a/src/ghdldrv/ghdllocal.ads +++ b/src/ghdldrv/ghdllocal.ads @@ -156,5 +156,9 @@ package Ghdllocal is -- name is incorrect. function Decode_Generic_Override_Option (Opt : String) return Option_State; + -- Emit a warning if an argument is not a filename (ie looks like an + -- option). + procedure Expect_Filenames (Args : Argument_List); + procedure Register_Commands; end Ghdllocal; -- cgit v1.2.3