aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2013-06-17 09:48:21 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2013-06-17 09:48:21 +0200
commitfa86f4f91765f138deaa410038fd9b58ec605560 (patch)
treef0f53ca508f0a7d7947323827651db99fab185cc /gcc
parent7e55aae9e3c253d58656022bb35850a9ed3afc98 (diff)
downloadgcc-fa86f4f91765f138deaa410038fd9b58ec605560.zip
gcc-fa86f4f91765f138deaa410038fd9b58ec605560.tar.gz
gcc-fa86f4f91765f138deaa410038fd9b58ec605560.tar.bz2
gfortran.h (gfc_option_t): Add fpe_summary.
2013-06-17 Tobias Burnus <burnus@net-b.de> * gfortran.h (gfc_option_t): Add fpe_summary. * gfortran.texi (_gfortran_set_options): Update. * invoke.texi (-ffpe-summary): Add doc. * lang.opt (ffpe-summary): Add flag. * options.c (gfc_init_options, gfc_handle_option): Handle it. (gfc_handle_fpe_option): Renamed from gfc_handle_fpe_trap_option, also handle fpe_summary. * trans-decl.c (create_main_function): Update _gfortran_set_options call. 2013-06-17 Tobias Burnus <burnus@net-b.de> * libgfortran.h (compile_options_t) Add fpe_summary. (get_fpu_except_flags): New prototype. * runtime/compile_options.c (set_options, init_compile_options): Handle fpe_summary. * runtime/stop.c (report_exception): New function. (stop_numeric, stop_numeric_f08, stop_string, error_stop_string, error_stop_numeric): Call it. * config/fpu-387.h (get_fpu_except_flags): New function. * config/fpu-aix.h (get_fpu_except_flags): New function. * config/fpu-generic.h (get_fpu_except_flags): New function. * config/fpu-glibc.h (get_fpu_except_flags): New function. * config/fpu-glibc.h (get_fpu_except_flags): New function. * configure.ac: Check for fpxcp.h. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r200147
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog12
-rw-r--r--gcc/fortran/gfortran.h1
-rw-r--r--gcc/fortran/gfortran.texi16
-rw-r--r--gcc/fortran/invoke.texi13
-rw-r--r--gcc/fortran/lang.opt4
-rw-r--r--gcc/fortran/options.c51
-rw-r--r--gcc/fortran/trans-decl.c11
7 files changed, 91 insertions, 17 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index b003bac..686a8e9 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,15 @@
+2013-06-17 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.h (gfc_option_t): Add fpe_summary.
+ * gfortran.texi (_gfortran_set_options): Update.
+ * invoke.texi (-ffpe-summary): Add doc.
+ * lang.opt (ffpe-summary): Add flag.
+ * options.c (gfc_init_options, gfc_handle_option): Handle it.
+ (gfc_handle_fpe_option): Renamed from gfc_handle_fpe_trap_option,
+ also handle fpe_summary.
+ * trans-decl.c (create_main_function): Update
+ _gfortran_set_options call.
+
2013-06-15 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/49074
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 14da0af..c11ffdd 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2303,6 +2303,7 @@ typedef struct
int flag_frontend_optimize;
int fpe;
+ int fpe_summary;
int rtcheck;
gfc_fcoarray coarray;
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 4a31a77..ad8cacc 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2846,7 +2846,7 @@ standard error. Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}.
Default: off.
@item @var{option}[3] @tab Unused.
@item @var{option}[4] @tab If non zero, enable backtracing on run-time
-errors. Default: off.
+errors. Default: off. (Default in the compiler: on.)
Note: Installs a signal handler and requires command-line
initialization using @code{_gfortran_set_args}.
@item @var{option}[5] @tab If non zero, supports signed zeros.
@@ -2855,13 +2855,21 @@ Default: enabled.
are (bitwise or-ed): GFC_RTCHECK_BOUNDS (1), GFC_RTCHECK_ARRAY_TEMPS (2),
GFC_RTCHECK_RECURSION (4), GFC_RTCHECK_DO (16), GFC_RTCHECK_POINTER (32).
Default: disabled.
+@item @var{option}[7] @tab Unused.
+@item @var{option}[8] @tab Show a warning when invoking @code{STOP} and
+@code{ERROR STOP} if a floating-point exception occurred. Possible values
+are (bitwise or-ed) @code{GFC_FPE_INVALID} (1), @code{GFC_FPE_DENORMAL} (2),
+@code{GFC_FPE_ZERO} (4), @code{GFC_FPE_OVERFLOW} (8),
+@code{GFC_FPE_UNDERFLOW} (16), @code{GFC_FPE_INEXACT} (32). Default: None (0).
+(Default in the compiler: @code{GFC_FPE_INVALID | GFC_FPE_DENORMAL |
+GFC_FPE_ZERO | GFC_FPE_OVERFLOW | GFC_FPE_UNDERFLOW}.)
@end multitable
@item @emph{Example}:
@smallexample
- /* Use gfortran 4.8 default options. */
- static int options[] = @{68, 511, 0, 0, 1, 1, 0@};
- _gfortran_set_options (7, &options);
+ /* Use gfortran 4.9 default options. */
+ static int options[] = @{68, 511, 0, 0, 1, 1, 0, 0, 31@};
+ _gfortran_set_options (9, &options);
@end smallexample
@end table
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 12c200e..3af57a3 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -151,7 +151,7 @@ and warnings}.
@item Debugging Options
@xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
@gccoptlist{-fbacktrace -fdump-fortran-optimized -fdump-fortran-original @gol
--fdump-parse-tree -ffpe-trap=@var{list}
+-fdump-parse-tree -ffpe-trap=@var{list} -ffpe-summary=@var{list}
}
@item Directory Options
@@ -1021,6 +1021,17 @@ be uninteresting in practice.
By default no exception traps are enabled.
+@item -ffpe-summary=@var{list}
+@opindex @code{ffpe-summary=}@var{list}
+Specify a list of floating-point exceptions, whose flag status is printed
+to @code{ERROR_UNIT} when invoking @code{STOP} and @code{ERROR STOP}.
+@var{list} can be either @samp{none}, @samp{all} or a comma-separated list
+of the following exceptions: @samp{invalid}, @samp{zero}, @samp{overflow},
+@samp{underflow}, @samp{inexact} and @samp{denormal}. (See
+@option{-ffpe-trap} for a description of the exceptions.)
+
+By default, a summary for all exceptions but @samp{inexact} is shown.
+
@item -fno-backtrace
@opindex @code{fno-backtrace}
@cindex backtrace
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index dbc3f6b..61f77b4 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -441,6 +441,10 @@ ffpe-trap=
Fortran RejectNegative JoinedOrMissing
-ffpe-trap=[...] Stop on following floating point exceptions
+ffpe-summary=
+Fortran RejectNegative JoinedOrMissing
+-ffpe-summary=[...] Print summary of floating point exceptions
+
ffree-form
Fortran RejectNegative
Assume that the source file is free form
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 3f5de03..908b47e 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -161,6 +161,10 @@ gfc_init_options (unsigned int decoded_options_count,
gfc_option.flag_frontend_optimize = -1;
gfc_option.fpe = 0;
+ /* All except GFC_FPE_INEXACT. */
+ gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
+ | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
+ | GFC_FPE_UNDERFLOW;
gfc_option.rtcheck = 0;
gfc_option.coarray = GFC_FCOARRAY_NONE;
@@ -492,8 +496,10 @@ gfc_handle_module_path_options (const char *arg)
}
+/* Handle options -ffpe-trap= and -ffpe-summary=. */
+
static void
-gfc_handle_fpe_trap_option (const char *arg)
+gfc_handle_fpe_option (const char *arg, bool trap)
{
int result, pos = 0, n;
/* precision is a backwards compatibility alias for inexact. */
@@ -505,7 +511,11 @@ gfc_handle_fpe_trap_option (const char *arg)
GFC_FPE_UNDERFLOW, GFC_FPE_INEXACT,
GFC_FPE_INEXACT,
0 };
-
+
+ /* As the default for -ffpe-summary= is nonzero, set it to 0. */
+ if (!trap)
+ gfc_option.fpe_summary = 0;
+
while (*arg)
{
while (*arg == ',')
@@ -515,19 +525,42 @@ gfc_handle_fpe_trap_option (const char *arg)
pos++;
result = 0;
- for (n = 0; exception[n] != NULL; n++)
+ if (!trap && strncmp ("none", arg, pos) == 0)
{
+ gfc_option.fpe_summary = 0;
+ arg += pos;
+ pos = 0;
+ continue;
+ }
+ else if (!trap && strncmp ("all", arg, pos) == 0)
+ {
+ gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
+ | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
+ | GFC_FPE_UNDERFLOW | GFC_FPE_INEXACT;
+ arg += pos;
+ pos = 0;
+ continue;
+ }
+ else
+ for (n = 0; exception[n] != NULL; n++)
+ {
if (exception[n] && strncmp (exception[n], arg, pos) == 0)
{
- gfc_option.fpe |= opt_exception[n];
+ if (trap)
+ gfc_option.fpe |= opt_exception[n];
+ else
+ gfc_option.fpe_summary |= opt_exception[n];
arg += pos;
pos = 0;
result = 1;
break;
}
- }
- if (!result)
+ }
+ if (!result && !trap)
gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg);
+ else if (!result)
+ gfc_fatal_error ("Argument to -ffpe-summary is not valid: %s", arg);
+
}
}
@@ -981,7 +1014,11 @@ gfc_handle_option (size_t scode, const char *arg, int value,
break;
case OPT_ffpe_trap_:
- gfc_handle_fpe_trap_option (arg);
+ gfc_handle_fpe_option (arg, true);
+ break;
+
+ case OPT_ffpe_summary_:
+ gfc_handle_fpe_option (arg, false);
break;
case OPT_std_f95:
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index f04ebdc..4e3bf48 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5203,14 +5203,15 @@ create_main_function (tree fndecl)
/* TODO: This is the -frange-check option, which no longer affects
library behavior; when bumping the library ABI this slot can be
reused for something else. As it is the last element in the
- array, we can instead leave it out altogether.
+ array, we can instead leave it out altogether. */
+ CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
+ build_int_cst (integer_type_node, 0));
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
- gfc_option.flag_range_check));
- */
+ gfc_option.fpe_summary));
array_type = build_array_type (integer_type_node,
- build_index_type (size_int (6)));
+ build_index_type (size_int (8)));
array = build_constructor (array_type, v);
TREE_CONSTANT (array) = 1;
TREE_STATIC (array) = 1;
@@ -5225,7 +5226,7 @@ create_main_function (tree fndecl)
tmp = build_call_expr_loc (input_location,
gfor_fndecl_set_options, 2,
- build_int_cst (integer_type_node, 7), var);
+ build_int_cst (integer_type_node, 9), var);
gfc_add_expr_to_block (&body, tmp);
}