]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Initialize gnat_argc/gnat_argv only the first time
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:47:53 +0000 (09:47 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:47:53 +0000 (09:47 +0000)
2019-08-20  Philippe Gil  <gil@adacore.com>

gcc/ada/

* bindgen.adb (Gen_Main): Set gnat_argc/gnat_argv to argc/argv
only when still uninitialized.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274716 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/bindgen.adb

index 91128b41d261a01db78e9bface1b26ae37db99a4..8485a9c0d09503e8b0742fa27fe5fd1021e32b50 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-20  Philippe Gil  <gil@adacore.com>
+
+       * bindgen.adb (Gen_Main): Set gnat_argc/gnat_argv to argc/argv
+       only when still uninitialized.
+
 2019-08-20  Bob Duff  <duff@adacore.com>
 
        * libgnat/g-comlin.ads (Exit_From_Command_Line): Fix
index 8ea8a6b94da024c04a7a7984e9afde02c235cc20..153043c8678f1d0c6c6f9e1f2c60d81ebe9b5786 100644 (file)
@@ -1826,18 +1826,25 @@ package body Bindgen is
 
       WBI ("   begin");
 
-      --  Acquire command line arguments if present on target
+      --  Acquire command-line arguments if present on target
 
       if CodePeer_Mode then
          null;
 
       elsif Command_Line_Args_On_Target then
-         WBI ("      gnat_argc := argc;");
-         WBI ("      gnat_argv := argv;");
+
+         --  Initialize gnat_argc/gnat_argv only if not already initialized,
+         --  to avoid losing the result of any command-line processing done by
+         --  earlier GNAT run-time initialization.
+
+         WBI ("      if gnat_argc = 0 then");
+         WBI ("         gnat_argc := argc;");
+         WBI ("         gnat_argv := argv;");
+         WBI ("      end if;");
          WBI ("      gnat_envp := envp;");
          WBI ("");
 
-      --  If configurable run time and no command line args, then nothing needs
+      --  If configurable run-time and no command-line args, then nothing needs
       --  to be done since the gnat_argc/argv/envp variables are suppressed in
       --  this case.