Some embedded targets set argc to zero when calling main, but then
pr126194 testcase fails because it uses argc > 0 to enable the code
that allows the test to pass.  Derive the argc passed to the primary
LTOed entry point from argc >= 0, so that it isn't a link-time
constant, but the guarding condition always passes at runtime.

Regstrapped on x86_64-linux-gnu.  Also tested with gcc-15 on embedded
targets whose C runtimes call main(0,0).  Ok to install?


for  gcc/testsuite/ChangeLog

        PR tree-optimization/126194
        * g++.dg/lto/pr126194_2.C (main): Tolerate argc == 0.
---
 gcc/testsuite/g++.dg/lto/pr126194_2.C |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/lto/pr126194_2.C 
b/gcc/testsuite/g++.dg/lto/pr126194_2.C
index 3c024f47a196b..9725a4239cdf0 100644
--- a/gcc/testsuite/g++.dg/lto/pr126194_2.C
+++ b/gcc/testsuite/g++.dg/lto/pr126194_2.C
@@ -4,5 +4,5 @@ extern "C" int run_repro(int argc);
 
 int main(int argc, char**)
 {
-    return run_repro(argc);
+    return run_repro(argc >= 0);
 }

-- 
Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!

Reply via email to