2004-05-13 08:41:07 +02:00
|
|
|
/* Implementation of the STOP statement.
|
2018-01-03 11:03:58 +01:00
|
|
|
Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
2004-05-13 08:41:07 +02:00
|
|
|
Contributed by Paul Brook <paul@nowt.org>
|
|
|
|
|
2011-05-14 09:55:51 +02:00
|
|
|
This file is part of the GNU Fortran runtime library (libgfortran).
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
Libgfortran is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
2004-05-13 08:41:07 +02:00
|
|
|
License as published by the Free Software Foundation; either
|
2009-04-09 17:00:19 +02:00
|
|
|
version 3 of the License, or (at your option) any later version.
|
2005-01-12 22:27:33 +01:00
|
|
|
|
|
|
|
Libgfortran is distributed in the hope that it will be useful,
|
2004-05-13 08:41:07 +02:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-01-12 22:27:33 +01:00
|
|
|
GNU General Public License for more details.
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
#include "libgfortran.h"
|
2013-05-04 23:23:11 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2011-05-14 09:55:51 +02:00
|
|
|
#include <unistd.h>
|
2013-05-04 23:23:11 +02:00
|
|
|
#endif
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2013-06-17 09:48:21 +02:00
|
|
|
/* Fortran 2008 demands: If any exception (14) is signaling on that image, the
|
|
|
|
processor shall issue a warning indicating which exceptions are signaling;
|
|
|
|
this warning shall be on the unit identified by the named constant
|
|
|
|
ERROR_UNIT (13.8.2.8). In line with other compilers, we do not report
|
|
|
|
inexact - and we optionally ignore underflow, cf. thread starting at
|
|
|
|
http://mailman.j3-fortran.org/pipermail/j3/2013-June/006452.html. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
report_exception (void)
|
|
|
|
{
|
|
|
|
int set_excepts;
|
|
|
|
|
|
|
|
if (!compile_options.fpe_summary)
|
|
|
|
return;
|
|
|
|
|
|
|
|
set_excepts = get_fpu_except_flags ();
|
|
|
|
if ((set_excepts & compile_options.fpe_summary) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
estr_write ("Note: The following floating-point exceptions are signalling:");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_INVALID)
|
|
|
|
&& (set_excepts & GFC_FPE_INVALID))
|
|
|
|
estr_write (" IEEE_INVALID_FLAG");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_ZERO)
|
|
|
|
&& (set_excepts & GFC_FPE_ZERO))
|
|
|
|
estr_write (" IEEE_DIVIDE_BY_ZERO");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_OVERFLOW)
|
|
|
|
&& (set_excepts & GFC_FPE_OVERFLOW))
|
|
|
|
estr_write (" IEEE_OVERFLOW_FLAG");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_UNDERFLOW)
|
|
|
|
&& (set_excepts & GFC_FPE_UNDERFLOW))
|
|
|
|
estr_write (" IEEE_UNDERFLOW_FLAG");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_DENORMAL)
|
|
|
|
&& (set_excepts & GFC_FPE_DENORMAL))
|
|
|
|
estr_write (" IEEE_DENORMAL");
|
|
|
|
|
|
|
|
if ((compile_options.fpe_summary & GFC_FPE_INEXACT)
|
|
|
|
&& (set_excepts & GFC_FPE_INEXACT))
|
|
|
|
estr_write (" IEEE_INEXACT_FLAG");
|
|
|
|
|
|
|
|
estr_write ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-20 06:44:11 +02:00
|
|
|
/* A numeric STOP statement. */
|
|
|
|
|
2018-02-23 10:07:24 +01:00
|
|
|
extern _Noreturn void stop_numeric (int, bool);
|
2010-05-20 06:44:11 +02:00
|
|
|
export_proto(stop_numeric);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
void
|
2018-02-23 10:07:24 +01:00
|
|
|
stop_numeric (int code, bool quiet)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2018-02-23 10:07:24 +01:00
|
|
|
if (!quiet)
|
|
|
|
{
|
|
|
|
report_exception ();
|
|
|
|
st_printf ("STOP %d\n", code);
|
|
|
|
}
|
2011-05-14 10:44:09 +02:00
|
|
|
exit (code);
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
|
|
|
|
2010-10-21 02:45:15 +02:00
|
|
|
|
2010-05-20 06:44:11 +02:00
|
|
|
/* A character string or blank STOP statement. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
void
|
2018-02-23 10:07:24 +01:00
|
|
|
stop_string (const char *string, size_t len, bool quiet)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2018-02-23 10:07:24 +01:00
|
|
|
if (!quiet)
|
2010-05-20 21:40:30 +02:00
|
|
|
{
|
2018-02-23 10:07:24 +01:00
|
|
|
report_exception ();
|
|
|
|
if (string)
|
|
|
|
{
|
|
|
|
estr_write ("STOP ");
|
|
|
|
(void) write (STDERR_FILENO, string, len);
|
|
|
|
estr_write ("\n");
|
|
|
|
}
|
2010-05-20 21:40:30 +02:00
|
|
|
}
|
2011-05-14 10:44:09 +02:00
|
|
|
exit (0);
|
2004-05-13 08:41:07 +02:00
|
|
|
}
|
re PR fortran/39997 (Procedure(), pointer & implicit typing: rejects-valid / accepts-invalid?)
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* intrinsic.c (add_functions): Add num_images.
* decl.c (gfc_match_end): Handle END CRITICAL.
* intrinsic.h (gfc_simplify_num_images): Add prototype.
* dump-parse-tree.c (show_code_node): Dump CRITICAL, ERROR STOP,
and SYNC.
* gfortran.h (gfc_statement): Add enum items for those.
(gfc_exec_op) Ditto.
(gfc_isym_id): Add num_images.
* trans-stmt.c (gfc_trans_stop): Handle ERROR STOP.
(gfc_trans_sync,gfc_trans_critical): New functions.
* trans-stmt.h (gfc_trans_stop,gfc_trans_sync,
gfc_trans_critical): Add/update prototypes.
* trans.c (gfc_trans_code): Handle CRITICAL, ERROR STOP,
and SYNC statements.
* trans.h (gfor_fndecl_error_stop_string) Add variable.
* resolve.c (resolve_sync): Add function.
(gfc_resolve_blocks): Handle CRITICAL.
(resolve_code): Handle CRITICAL, ERROR STOP,
(resolve_branch): Add CRITICAL constraint check.
and SYNC statements.
* st.c (gfc_free_statement): Add new statements.
* trans-decl.c (gfor_fndecl_error_stop_string): Global variable.
(gfc_build_builtin_function_decls): Initialize it.
* match.c (gfc_match_if): Handle ERROR STOP and SYNC.
(gfc_match_critical, gfc_match_error_stop, sync_statement,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory):
New functions.
(match_exit_cycle): Handle CRITICAL constraint.
(gfc_match_stopcode): Handle ERROR STOP.
* match.h (gfc_match_critical, gfc_match_error_stop,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory): Add prototype.
* parse.c (decode_statement, gfc_ascii_statement,
parse_executable): Handle new statements.
(parse_critical_block): New function.
* parse.h (gfc_compile_state): Add COMP_CRITICAL.
* intrinsic.texi (num_images): Document new function.
* simplify.c (gfc_simplify_num_images): Add function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* gfortran.dg/coarray_1.f90: New test.
* gfortran.dg/coarray_2.f90: New test.
* gfortran.dg/coarray_3.f90: New test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* runtime/stop.c (error_stop_string): New function.
* gfortran.map (_gfortran_error_stop_string): Add.
From-SVN: r158008
2010-04-06 18:26:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* 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. */
|
2010-05-20 06:44:11 +02:00
|
|
|
|
2018-02-23 10:07:24 +01:00
|
|
|
extern _Noreturn void error_stop_string (const char *, size_t, bool);
|
2010-05-20 06:44:11 +02:00
|
|
|
export_proto(error_stop_string);
|
|
|
|
|
re PR fortran/39997 (Procedure(), pointer & implicit typing: rejects-valid / accepts-invalid?)
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* intrinsic.c (add_functions): Add num_images.
* decl.c (gfc_match_end): Handle END CRITICAL.
* intrinsic.h (gfc_simplify_num_images): Add prototype.
* dump-parse-tree.c (show_code_node): Dump CRITICAL, ERROR STOP,
and SYNC.
* gfortran.h (gfc_statement): Add enum items for those.
(gfc_exec_op) Ditto.
(gfc_isym_id): Add num_images.
* trans-stmt.c (gfc_trans_stop): Handle ERROR STOP.
(gfc_trans_sync,gfc_trans_critical): New functions.
* trans-stmt.h (gfc_trans_stop,gfc_trans_sync,
gfc_trans_critical): Add/update prototypes.
* trans.c (gfc_trans_code): Handle CRITICAL, ERROR STOP,
and SYNC statements.
* trans.h (gfor_fndecl_error_stop_string) Add variable.
* resolve.c (resolve_sync): Add function.
(gfc_resolve_blocks): Handle CRITICAL.
(resolve_code): Handle CRITICAL, ERROR STOP,
(resolve_branch): Add CRITICAL constraint check.
and SYNC statements.
* st.c (gfc_free_statement): Add new statements.
* trans-decl.c (gfor_fndecl_error_stop_string): Global variable.
(gfc_build_builtin_function_decls): Initialize it.
* match.c (gfc_match_if): Handle ERROR STOP and SYNC.
(gfc_match_critical, gfc_match_error_stop, sync_statement,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory):
New functions.
(match_exit_cycle): Handle CRITICAL constraint.
(gfc_match_stopcode): Handle ERROR STOP.
* match.h (gfc_match_critical, gfc_match_error_stop,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory): Add prototype.
* parse.c (decode_statement, gfc_ascii_statement,
parse_executable): Handle new statements.
(parse_critical_block): New function.
* parse.h (gfc_compile_state): Add COMP_CRITICAL.
* intrinsic.texi (num_images): Document new function.
* simplify.c (gfc_simplify_num_images): Add function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* gfortran.dg/coarray_1.f90: New test.
* gfortran.dg/coarray_2.f90: New test.
* gfortran.dg/coarray_3.f90: New test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* runtime/stop.c (error_stop_string): New function.
* gfortran.map (_gfortran_error_stop_string): Add.
From-SVN: r158008
2010-04-06 18:26:02 +02:00
|
|
|
void
|
2018-02-23 10:07:24 +01:00
|
|
|
error_stop_string (const char *string, size_t len, bool quiet)
|
re PR fortran/39997 (Procedure(), pointer & implicit typing: rejects-valid / accepts-invalid?)
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* intrinsic.c (add_functions): Add num_images.
* decl.c (gfc_match_end): Handle END CRITICAL.
* intrinsic.h (gfc_simplify_num_images): Add prototype.
* dump-parse-tree.c (show_code_node): Dump CRITICAL, ERROR STOP,
and SYNC.
* gfortran.h (gfc_statement): Add enum items for those.
(gfc_exec_op) Ditto.
(gfc_isym_id): Add num_images.
* trans-stmt.c (gfc_trans_stop): Handle ERROR STOP.
(gfc_trans_sync,gfc_trans_critical): New functions.
* trans-stmt.h (gfc_trans_stop,gfc_trans_sync,
gfc_trans_critical): Add/update prototypes.
* trans.c (gfc_trans_code): Handle CRITICAL, ERROR STOP,
and SYNC statements.
* trans.h (gfor_fndecl_error_stop_string) Add variable.
* resolve.c (resolve_sync): Add function.
(gfc_resolve_blocks): Handle CRITICAL.
(resolve_code): Handle CRITICAL, ERROR STOP,
(resolve_branch): Add CRITICAL constraint check.
and SYNC statements.
* st.c (gfc_free_statement): Add new statements.
* trans-decl.c (gfor_fndecl_error_stop_string): Global variable.
(gfc_build_builtin_function_decls): Initialize it.
* match.c (gfc_match_if): Handle ERROR STOP and SYNC.
(gfc_match_critical, gfc_match_error_stop, sync_statement,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory):
New functions.
(match_exit_cycle): Handle CRITICAL constraint.
(gfc_match_stopcode): Handle ERROR STOP.
* match.h (gfc_match_critical, gfc_match_error_stop,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory): Add prototype.
* parse.c (decode_statement, gfc_ascii_statement,
parse_executable): Handle new statements.
(parse_critical_block): New function.
* parse.h (gfc_compile_state): Add COMP_CRITICAL.
* intrinsic.texi (num_images): Document new function.
* simplify.c (gfc_simplify_num_images): Add function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* gfortran.dg/coarray_1.f90: New test.
* gfortran.dg/coarray_2.f90: New test.
* gfortran.dg/coarray_3.f90: New test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* runtime/stop.c (error_stop_string): New function.
* gfortran.map (_gfortran_error_stop_string): Add.
From-SVN: r158008
2010-04-06 18:26:02 +02:00
|
|
|
{
|
2018-02-23 10:07:24 +01:00
|
|
|
if (!quiet)
|
|
|
|
{
|
|
|
|
report_exception ();
|
|
|
|
estr_write ("ERROR STOP ");
|
|
|
|
(void) write (STDERR_FILENO, string, len);
|
|
|
|
estr_write ("\n");
|
|
|
|
}
|
2015-09-05 00:17:11 +02:00
|
|
|
exit_error (1);
|
re PR fortran/39997 (Procedure(), pointer & implicit typing: rejects-valid / accepts-invalid?)
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* intrinsic.c (add_functions): Add num_images.
* decl.c (gfc_match_end): Handle END CRITICAL.
* intrinsic.h (gfc_simplify_num_images): Add prototype.
* dump-parse-tree.c (show_code_node): Dump CRITICAL, ERROR STOP,
and SYNC.
* gfortran.h (gfc_statement): Add enum items for those.
(gfc_exec_op) Ditto.
(gfc_isym_id): Add num_images.
* trans-stmt.c (gfc_trans_stop): Handle ERROR STOP.
(gfc_trans_sync,gfc_trans_critical): New functions.
* trans-stmt.h (gfc_trans_stop,gfc_trans_sync,
gfc_trans_critical): Add/update prototypes.
* trans.c (gfc_trans_code): Handle CRITICAL, ERROR STOP,
and SYNC statements.
* trans.h (gfor_fndecl_error_stop_string) Add variable.
* resolve.c (resolve_sync): Add function.
(gfc_resolve_blocks): Handle CRITICAL.
(resolve_code): Handle CRITICAL, ERROR STOP,
(resolve_branch): Add CRITICAL constraint check.
and SYNC statements.
* st.c (gfc_free_statement): Add new statements.
* trans-decl.c (gfor_fndecl_error_stop_string): Global variable.
(gfc_build_builtin_function_decls): Initialize it.
* match.c (gfc_match_if): Handle ERROR STOP and SYNC.
(gfc_match_critical, gfc_match_error_stop, sync_statement,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory):
New functions.
(match_exit_cycle): Handle CRITICAL constraint.
(gfc_match_stopcode): Handle ERROR STOP.
* match.h (gfc_match_critical, gfc_match_error_stop,
gfc_match_sync_all, gfc_match_sync_images,
gfc_match_sync_memory): Add prototype.
* parse.c (decode_statement, gfc_ascii_statement,
parse_executable): Handle new statements.
(parse_critical_block): New function.
* parse.h (gfc_compile_state): Add COMP_CRITICAL.
* intrinsic.texi (num_images): Document new function.
* simplify.c (gfc_simplify_num_images): Add function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* gfortran.dg/coarray_1.f90: New test.
* gfortran.dg/coarray_2.f90: New test.
* gfortran.dg/coarray_3.f90: New test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/39997
* runtime/stop.c (error_stop_string): New function.
* gfortran.map (_gfortran_error_stop_string): Add.
From-SVN: r158008
2010-04-06 18:26:02 +02:00
|
|
|
}
|
2010-05-20 06:44:11 +02:00
|
|
|
|
2010-10-21 02:45:15 +02:00
|
|
|
|
|
|
|
/* A numeric ERROR STOP statement. */
|
2010-05-20 06:44:11 +02:00
|
|
|
|
2018-02-23 10:07:24 +01:00
|
|
|
extern _Noreturn void error_stop_numeric (int, bool);
|
2010-05-20 06:44:11 +02:00
|
|
|
export_proto(error_stop_numeric);
|
|
|
|
|
|
|
|
void
|
2018-02-23 10:07:24 +01:00
|
|
|
error_stop_numeric (int code, bool quiet)
|
2010-05-20 06:44:11 +02:00
|
|
|
{
|
2018-02-23 10:07:24 +01:00
|
|
|
if (!quiet)
|
|
|
|
{
|
|
|
|
report_exception ();
|
|
|
|
st_printf ("ERROR STOP %d\n", code);
|
|
|
|
}
|
2015-09-05 00:17:11 +02:00
|
|
|
exit_error (code);
|
2010-05-20 06:44:11 +02:00
|
|
|
}
|