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

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

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

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

From-SVN: r253593

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 e73439f2df1ea73bd9b7123b89ffb45b198f3cf7..ae985df779228e965360cd30bbaa4cc6d2c6c17f 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/82233
+       * gfortran.dg/execute_command_line_3.f90: New test.
+
 2017-10-10  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        * gcc.target/powerpc/fold-vec-splat-16.c: New
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..87d73d1
--- /dev/null
@@ -0,0 +1,24 @@
+! { 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 )
+   print *,msg
+   if (msg /= '') call abort
+   call execute_command_line(command ,               exitstat=i, cmdstat=j             )
+   if (j /= 3) call abort
+   call execute_command_line(command , wait=.false., exitstat=i                        )
+
+end program boom
index be954b64e9263b559c6a96b8aa9929666c453c46..ef9ef19b68b6d53e70eb130b8392289246fc4724 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/82233
+       * intrinsics/execute_command_line.c (execute_command_line):
+       No call to runtime_error if cmdstat is present.
+
 2017-09-24  Dominique d'Humieres  <dominiq@lps.ens.fr>
 
        PR libgfortran/79612
index 339d1bbe1899293f0c9ee112c25c1eda2594f51c..31ab36de9d8d5c3183f33abefcce0cc7d019460e 100644 (file)
@@ -125,15 +125,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]);
-    }
 }