aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/grt/ghdl_main.adb12
-rw-r--r--testsuite/gna/issue1206/main_notnull.c8
-rwxr-xr-xtestsuite/gna/issue1206/testsuite.sh14
3 files changed, 24 insertions, 10 deletions
diff --git a/src/grt/ghdl_main.adb b/src/grt/ghdl_main.adb
index 3107da23c..9a4710b4c 100644
--- a/src/grt/ghdl_main.adb
+++ b/src/grt/ghdl_main.adb
@@ -44,19 +44,17 @@ is
function To_Argv_Type is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Grt.Options.Argv_Type);
- My_Argv : Grt.Options.Argv_Type := To_Argv_Type (Argv);
- Progname : Ghdl_C_String;
+ Args : Grt.Options.Argv_Type := To_Argv_Type (Argv);
+ Progname : Ghdl_C_String := null;
begin
-- Ada elaboration.
Grt_Init;
-- Set the options.
- if Argc > 0 then
- Progname := My_Argv (0);
- else
- Progname := null;
+ if not (Argc = 0 and Args = null) then
+ Progname := Args (0);
end if;
- Grt.Main.Run_Options (Progname, Argc, My_Argv);
+ Grt.Main.Run_Options (Progname, Argc, Args);
-- Initialize, elaborate and simulate.
Grt.Main.Run;
diff --git a/testsuite/gna/issue1206/main_notnull.c b/testsuite/gna/issue1206/main_notnull.c
new file mode 100644
index 000000000..9ff996f6f
--- /dev/null
+++ b/testsuite/gna/issue1206/main_notnull.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+extern int ghdl_main(int argc, char** argv);
+
+int main(int argc, char** argv) {
+ printf("ghdl_main: %d\n", ghdl_main(argc, argv));
+ return 0;
+}
diff --git a/testsuite/gna/issue1206/testsuite.sh b/testsuite/gna/issue1206/testsuite.sh
index bd0773227..09532b329 100755
--- a/testsuite/gna/issue1206/testsuite.sh
+++ b/testsuite/gna/issue1206/testsuite.sh
@@ -1,15 +1,23 @@
#! /bin/sh
+cd $(dirname "$0")
+
. ../../testenv.sh
if $GHDL --help | grep -q -e --link; then
if [ -z $CC ]; then
- CC="gcc"
+ CC="gcc"
fi
- $CC -c main.c
analyze hello.vhdl
- elab -Wl,main.o hello
+ elab -Wl,main.c hello
+ run ./hello
+
+ clean
+ rm -f main.o
+
+ analyze hello.vhdl
+ elab -Wl,main_notnull.c hello
run ./hello
clean