aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/options.c')
-rw-r--r--gcc/fortran/options.c51
1 files changed, 44 insertions, 7 deletions
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: