2004-05-13 08:41:07 +02:00
|
|
|
/* Implementation of the STOP statement.
|
2013-01-14 19:20:58 +01:00
|
|
|
Copyright (C) 2002-2013 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"
|
2011-07-23 13:06:04 +02:00
|
|
|
#include <stdlib.h>
|
2007-08-31 16:01:34 +02:00
|
|
|
#include <string.h>
|
2011-05-14 09:55:51 +02:00
|
|
|
#include <unistd.h>
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2010-05-20 06:44:11 +02:00
|
|
|
/* A numeric STOP statement. */
|
|
|
|
|
|
|
|
extern void stop_numeric (GFC_INTEGER_4)
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
export_proto(stop_numeric);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
void
|
|
|
|
stop_numeric (GFC_INTEGER_4 code)
|
2010-10-21 02:45:15 +02:00
|
|
|
{
|
|
|
|
if (code == -1)
|
|
|
|
code = 0;
|
|
|
|
else
|
|
|
|
st_printf ("STOP %d\n", (int)code);
|
|
|
|
|
2011-05-14 10:44:09 +02:00
|
|
|
exit (code);
|
2010-10-21 02:45:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* A Fortran 2008 numeric STOP statement. */
|
|
|
|
|
|
|
|
extern void stop_numeric_f08 (GFC_INTEGER_4)
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
export_proto(stop_numeric_f08);
|
|
|
|
|
|
|
|
void
|
|
|
|
stop_numeric_f08 (GFC_INTEGER_4 code)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2010-05-20 06:44:11 +02:00
|
|
|
st_printf ("STOP %d\n", (int)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
|
|
|
|
stop_string (const char *string, GFC_INTEGER_4 len)
|
|
|
|
{
|
2010-05-20 21:40:30 +02:00
|
|
|
if (string)
|
|
|
|
{
|
2011-05-14 09:55:51 +02:00
|
|
|
estr_write ("STOP ");
|
2011-05-22 21:34:16 +02:00
|
|
|
(void) write (STDERR_FILENO, string, len);
|
2011-05-14 09:55:51 +02:00
|
|
|
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
|
|
|
|
|
|
|
extern void error_stop_string (const char *, GFC_INTEGER_4)
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
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
|
|
|
|
error_stop_string (const char *string, GFC_INTEGER_4 len)
|
|
|
|
{
|
2011-05-14 09:55:51 +02:00
|
|
|
estr_write ("ERROR STOP ");
|
2011-05-22 21:34:16 +02:00
|
|
|
(void) write (STDERR_FILENO, string, len);
|
2011-05-14 09:55:51 +02:00
|
|
|
estr_write ("\n");
|
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
|
|
|
|
2011-05-14 18:02:07 +02:00
|
|
|
exit (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
|
|
|
|
|
|
|
extern void error_stop_numeric (GFC_INTEGER_4)
|
|
|
|
__attribute__ ((noreturn));
|
|
|
|
export_proto(error_stop_numeric);
|
|
|
|
|
|
|
|
void
|
|
|
|
error_stop_numeric (GFC_INTEGER_4 code)
|
|
|
|
{
|
|
|
|
st_printf ("ERROR STOP %d\n", (int) code);
|
2011-05-14 10:44:09 +02:00
|
|
|
exit (code);
|
2010-05-20 06:44:11 +02:00
|
|
|
}
|