diff options
author | tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-04-19 08:53:38 +0000 |
---|---|---|
committer | tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-04-19 08:53:38 +0000 |
commit | 6bc09e4fa2e5e59dee18f1c03f2d6529b9b0045b (patch) | |
tree | 24ddf33011e25e1eeddf1b584fb5a990e27ed36e /libgfortran/runtime | |
parent | e077efa5805f81288e631af0a3e075f27ceb45de (diff) |
PR85463 '[nvptx] "exit" in offloaded region doesn't terminate process'
libgomp/
PR libfortran/85166
* testsuite/libgomp.oacc-fortran/abort-1.f90: Switch back to "call
abort".
* testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise.
libgfortran/
PR libfortran/85166
PR libgomp/85463
* runtime/minimal.c (stop_numeric): Reimplement.
(stop_string, error_stop_string, error_stop_numeric): New
functions.
libgomp/
PR libgomp/85463
* testsuite/libgomp.oacc-fortran/error_stop-1.f: New file.
* testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-1.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-3.f: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259491 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r-- | libgfortran/runtime/minimal.c | 80 |
1 files changed, 78 insertions, 2 deletions
diff --git a/libgfortran/runtime/minimal.c b/libgfortran/runtime/minimal.c index e17666b7b82..0b1efeb0d58 100644 --- a/libgfortran/runtime/minimal.c +++ b/libgfortran/runtime/minimal.c @@ -188,6 +188,22 @@ sys_abort (void) abort(); } + +/* runtime/stop.c */ + +#undef report_exception +#define report_exception() do {} while (0) +#undef st_printf +#define st_printf printf +#undef estr_write +#define estr_write printf +/* Map "exit" to "abort"; see PR85463 '[nvptx] "exit" in offloaded region + doesn't terminate process'. */ +#undef exit +#define exit(...) do { abort (); } while (0) +#undef exit_error +#define exit_error(...) do { abort (); } while (0) + /* A numeric STOP statement. */ extern _Noreturn void stop_numeric (int, bool); @@ -197,7 +213,67 @@ void stop_numeric (int code, bool quiet) { if (!quiet) - printf ("STOP %d\n", code); - + { + report_exception (); + st_printf ("STOP %d\n", code); + } exit (code); } + + +/* A character string or blank STOP statement. */ + +void +stop_string (const char *string, size_t len, bool quiet) +{ + if (!quiet) + { + report_exception (); + if (string) + { + estr_write ("STOP "); + (void) write (STDERR_FILENO, string, len); + estr_write ("\n"); + } + } + exit (0); +} + + +/* Per Fortran 2008, section 8.4: "Execution of a STOP statement initiates + normal termination of execution. Execution of an ERROR STOP statement + 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, bool); +export_proto(error_stop_string); + +void +error_stop_string (const char *string, size_t len, bool quiet) +{ + 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, bool); +export_proto(error_stop_numeric); + +void +error_stop_numeric (int code, bool quiet) +{ + if (!quiet) + { + report_exception (); + st_printf ("ERROR STOP %d\n", code); + } + exit_error (code); +} |