From: Thomas Koenig Date: Tue, 10 Oct 2017 16:49:32 +0000 (+0000) Subject: re PR libfortran/82233 (execute_command_line causes program to stop when command... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3934b625ee2f522edf455191d1eaaa42e265a1d9;p=gcc.git re PR libfortran/82233 (execute_command_line causes program to stop when command fails (or does not exist)) 2017-10-10 Thomas Koenig 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 PR libfortran/82233 * gfortran.dg/execute_command_line_3.f90: New test. From-SVN: r253593 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e73439f2df1..ae985df7792 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-10 Thomas Koenig + + PR libfortran/82233 + * gfortran.dg/execute_command_line_3.f90: New test. + 2017-10-10 Will Schmidt * 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 index 00000000000..87d73d1b50f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/execute_command_line_3.f90 @@ -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 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index be954b64e92..ef9ef19b68b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2017-10-10 Thomas Koenig + + 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 PR libgfortran/79612 diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c index 339d1bbe189..31ab36de9d8 100644 --- a/libgfortran/intrinsics/execute_command_line.c +++ b/libgfortran/intrinsics/execute_command_line.c @@ -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]); - } }