aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/runtime
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2018-02-23 11:07:24 +0200
committerJanne Blomqvist <jb@gcc.gnu.org>2018-02-23 11:07:24 +0200
commitdffb1e2279fc9df82b2817c87a9a6319e7508532 (patch)
tree858fec6d98338d83564c6149d999223d2f44d204 /libgfortran/runtime
parent355436fb15420a1b05d3e333f202fa3296b4baaf (diff)
downloadgcc-dffb1e2279fc9df82b2817c87a9a6319e7508532.zip
gcc-dffb1e2279fc9df82b2817c87a9a6319e7508532.tar.gz
gcc-dffb1e2279fc9df82b2817c87a9a6319e7508532.tar.bz2
PR 84519 Handle optional QUIET specifier for STOP and ERROR STOP
Fortran 2018 adds a new QUIET specifier for the STOP and ERROR STOP statements, in order to suppress the printing of signaling FP exceptions and the stop code. This patch adds the necessary library changes, but for now the new specifier is not parsed and the frontend unconditionally adds a false value for the new argument. Regtested on x86_64-pc-linux-gnu. gcc/fortran/ChangeLog: 2018-02-23 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/84519 * trans-decl.c (gfc_build_builtin_function_decls): Add bool argument to stop and error stop decls. * trans-stmt.c (gfc_trans_stop): Add false value to argument lists. libgfortran/ChangeLog: 2018-02-23 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/84519 * caf/libcaf.h (_gfortran_caf_stop_numeric): Add bool argument. (_gfortran_caf_stop_str): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. * caf/mpi.c (_gfortran_caf_error_stop_str): Handle new argument. (_gfortran_caf_error_stop): Likewise. * caf/single.c (_gfortran_caf_stop_numeric): Likewise. (_gfortran_caf_stop_str): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. (_gfortran_caf_lock): Likewise. (_gfortran_caf_unlock): Likewise. * libgfortran.h (stop_string): Add bool argument. * runtime/pause.c (do_pause): Add false argument. * runtime/stop.c (stop_numeric): Handle new argument. (stop_string): Likewise. (error_stop_string): Likewise. (error_stop_numeric): Likewise. From-SVN: r257928
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r--libgfortran/runtime/pause.c2
-rw-r--r--libgfortran/runtime/stop.c53
2 files changed, 33 insertions, 22 deletions
diff --git a/libgfortran/runtime/pause.c b/libgfortran/runtime/pause.c
index 3b4c17b..37672d4 100644
--- a/libgfortran/runtime/pause.c
+++ b/libgfortran/runtime/pause.c
@@ -40,7 +40,7 @@ do_pause (void)
fgets(buff, 4, stdin);
if (strncmp(buff, "go\n", 3) != 0)
- stop_string ('\0', 0);
+ stop_string ('\0', 0, false);
estr_write ("RESUMED\n");
}
diff --git a/libgfortran/runtime/stop.c b/libgfortran/runtime/stop.c
index 3ef1350..1e6dd8c 100644
--- a/libgfortran/runtime/stop.c
+++ b/libgfortran/runtime/stop.c
@@ -81,14 +81,17 @@ report_exception (void)
/* A numeric STOP statement. */
-extern _Noreturn void stop_numeric (int);
+extern _Noreturn void stop_numeric (int, bool);
export_proto(stop_numeric);
void
-stop_numeric (int code)
+stop_numeric (int code, bool quiet)
{
- report_exception ();
- st_printf ("STOP %d\n", code);
+ if (!quiet)
+ {
+ report_exception ();
+ st_printf ("STOP %d\n", code);
+ }
exit (code);
}
@@ -96,14 +99,17 @@ stop_numeric (int code)
/* A character string or blank STOP statement. */
void
-stop_string (const char *string, size_t len)
+stop_string (const char *string, size_t len, bool quiet)
{
- report_exception ();
- if (string)
+ if (!quiet)
{
- estr_write ("STOP ");
- (void) write (STDERR_FILENO, string, len);
- estr_write ("\n");
+ report_exception ();
+ if (string)
+ {
+ estr_write ("STOP ");
+ (void) write (STDERR_FILENO, string, len);
+ estr_write ("\n");
+ }
}
exit (0);
}
@@ -114,30 +120,35 @@ stop_string (const char *string, size_t len)
initiates error termination of execution." Thus, error_stop_string returns
a nonzero exit status code. */
-extern _Noreturn void error_stop_string (const char *, size_t);
+extern _Noreturn void error_stop_string (const char *, size_t, bool);
export_proto(error_stop_string);
void
-error_stop_string (const char *string, size_t len)
+error_stop_string (const char *string, size_t len, bool quiet)
{
- report_exception ();
- estr_write ("ERROR STOP ");
- (void) write (STDERR_FILENO, string, len);
- estr_write ("\n");
-
+ if (!quiet)
+ {
+ report_exception ();
+ estr_write ("ERROR STOP ");
+ (void) write (STDERR_FILENO, string, len);
+ estr_write ("\n");
+ }
exit_error (1);
}
/* A numeric ERROR STOP statement. */
-extern _Noreturn void error_stop_numeric (int);
+extern _Noreturn void error_stop_numeric (int, bool);
export_proto(error_stop_numeric);
void
-error_stop_numeric (int code)
+error_stop_numeric (int code, bool quiet)
{
- report_exception ();
- st_printf ("ERROR STOP %d\n", code);
+ if (!quiet)
+ {
+ report_exception ();
+ st_printf ("ERROR STOP %d\n", code);
+ }
exit_error (code);
}