From: Philippe Gil Date: Tue, 20 Aug 2019 09:47:53 +0000 (+0000) Subject: [Ada] Initialize gnat_argc/gnat_argv only the first time X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fdacd614f4162311af0e60a02e6ff6b47ba809a5;p=gcc.git [Ada] Initialize gnat_argc/gnat_argv only the first time 2019-08-20 Philippe Gil gcc/ada/ * bindgen.adb (Gen_Main): Set gnat_argc/gnat_argv to argc/argv only when still uninitialized. From-SVN: r274716 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 91128b41d26..8485a9c0d09 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-20 Philippe Gil + + * bindgen.adb (Gen_Main): Set gnat_argc/gnat_argv to argc/argv + only when still uninitialized. + 2019-08-20 Bob Duff * libgnat/g-comlin.ads (Exit_From_Command_Line): Fix diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index 8ea8a6b94da..153043c8678 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -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.