]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR libfortran/82233 (execute_command_line causes program to stop when...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 22 Oct 2017 14:21:16 +0000 (14:21 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 22 Oct 2017 14:21:16 +0000 (14:21 +0000)
2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

Backport from trunk
PR libfortran/82233
* intrinsics/execute_command_line.c (execute_command_line):
No call to runtime_error if cmdstat is present.

2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

Backport from trunk
PR libfortran/82233
* gfortran.dg/execute_command_line_3.f90: New test.

From-SVN: r253983

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/execute_command_line_3.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/intrinsics/execute_command_line.c

index 9541d54bbfd3588495d4a402c1f1fbecaf1627e5..ee8f8d97263a5a73e1036608ffe6847cfe6fda2a 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       Backport from trunk
+       PR libfortran/82233
+       * gfortran.dg/execute_command_line_3.f90: New test.
+
 2017-10-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
diff --git a/gcc/testsuite/gfortran.dg/execute_command_line_3.f90 b/gcc/testsuite/gfortran.dg/execute_command_line_3.f90
new file mode 100644 (file)
index 0000000..c1790d8
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do  run }
+! PR 82233 - there were program aborts for some of these commands.
+! Original test case by Urban Jost.
+program boom
+implicit none
+integer                       :: i,j 
+character(len=256)            :: msg
+character(len=:), allocatable :: command
+   command='notthere'
+   msg='' ! seems to only be defined if exitstatus.ne.0
+   ! ok -- these work
+   call execute_command_line(command , wait=.false., exitstat=i, cmdstat=j, cmdmsg=msg)
+   if (j /= 0 .or. msg /= '') call abort
+   call execute_command_line(command ,               exitstat=i, cmdstat=j, cmdmsg=msg )
+   if (j /= 3 .or. msg /= "Invalid command line" ) call abort
+   msg = ''
+   call execute_command_line(command , wait=.false., exitstat=i,            cmdmsg=msg )
+   if (j /= 3) call abort
+   call execute_command_line(command , wait=.false., exitstat=i                        )
+   if (msg /= '') call abort
+   call execute_command_line(command ,               exitstat=i, cmdstat=j             )
+
+end program boom
index c92542801160ad160f551fa4e4da5750a6db4204..dd0eb9c720ee15e11cc9dae99abad8d6b3d7bea9 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       Backport from trunk
+       PR libfortran/82233
+       * intrinsics/execute_command_line.c (execute_command_line):
+       No call to runtime_error if cmdstat is present.
+
 2017-07-04  Release Manager
 
        * GCC 6.4.0 released.
index c9f9176c2a20cf20915ce50a37f2d1e2c1e2dfb0..e355ff4be8657ca5ab25c59bd0af133ed2815ff2 100644 (file)
@@ -126,15 +126,9 @@ execute_command_line (const char *command, bool wait, int *exitstat,
   free (cmd);
 
   /* Now copy back to the Fortran string if needed.  */
-  if (cmdstat && *cmdstat > EXEC_NOERROR)
-    {
-      if (cmdmsg)
-       fstrcpy (cmdmsg, cmdmsg_len, cmdmsg_values[*cmdstat],
+  if (cmdstat && *cmdstat > EXEC_NOERROR && cmdmsg)
+    fstrcpy (cmdmsg, cmdmsg_len, cmdmsg_values[*cmdstat],
                strlen (cmdmsg_values[*cmdstat]));
-      else
-       runtime_error ("Failure in EXECUTE_COMMAND_LINE: %s",
-                      cmdmsg_values[*cmdstat]);
-    }
 }