diff options
author | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2005-10-12 20:21:31 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2005-10-12 20:21:31 +0000 |
commit | 944b8b35a92ccdde4c4fa5458a1b48d8e8a25412 (patch) | |
tree | af4f5409e807606750191918d192516dcd170012 /gcc/fortran/options.c | |
parent | f23a977ce50e244b7cda0d54d36e5b8e6d505795 (diff) | |
download | gcc-944b8b35a92ccdde4c4fa5458a1b48d8e8a25412.zip gcc-944b8b35a92ccdde4c4fa5458a1b48d8e8a25412.tar.gz gcc-944b8b35a92ccdde4c4fa5458a1b48d8e8a25412.tar.bz2 |
gfortran.h: Add bitmasks for different FPE traps.
* gfortran.h: Add bitmasks for different FPE traps. Add fpe
member to options_t.
* invoke.texi: Document the new -ffpe-trap option.
* lang.opt: Add -ffpe-trap option.
* options.c (gfc_init_options): Initialize the FPE option.
(gfc_handle_fpe_trap_option): New function to parse the argument
of the -ffpe-trap option.
(gfc_handle_option): Add case for -ffpe-trap.
* trans-decl.c: Declare a tree for the set_fpe library function.
(gfc_build_builtin_function_decls): Build this tree.
(gfc_generate_function_code): Generate a call to set_fpe at
the beginning of the main program.
* trans.h: New tree for the set_fpe library function.
* Makefile.am: Add fpu.c to the build process, and
target-dependent code as fpu-target.h.
* Makefile.in: Regenerate.
* configure.ac: Add call to configure.host to set
FPU_HOST_HEADER.
* configure: Regenerate.
* config.h.in: Regenerate.
* aclocal.m4: Regenerate.
* configure.host: New script to determine which host-dependent
code should go in.
* libgfortran.h: Add fpe option, remove previous fpu_ options.
Add bitmasks for different FPE traps. Add prototype for set_fpu.
* runtime/environ.c: Remove environment variables to control
fpu behaviour.
* runtime/fpu.c (set_fpe): New function for the front-end.
* runtime/main.c (init): Set FPU state.
* config: New directory to store host-dependent code.
* config/fpu-387.h: New file with code handling the i387 FPU.
* config/fpu-glibc.h: New file with code for glibc systems.
* config/fpu-generic.h: Fallback for the most generic host. Issue
warnings.
From-SVN: r105328
Diffstat (limited to 'gcc/fortran/options.c')
-rw-r--r-- | gcc/fortran/options.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 48df674..95720bf 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -76,6 +76,8 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, gfc_option.q_kind = gfc_default_double_kind; + gfc_option.fpe = 0; + flag_argument_noalias = 2; flag_errno_math = 0; @@ -278,6 +280,41 @@ gfc_handle_module_path_options (const char *arg) strcat (gfc_option.module_dir, "/"); } +static void +gfc_handle_fpe_trap_option (const char *arg) +{ + int result, pos = 0, n; + static const char * const exception[] = { "invalid", "denormal", "zero", + "overflow", "underflow", + "precision", NULL }; + static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL, + GFC_FPE_ZERO, GFC_FPE_OVERFLOW, + GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION, + 0 }; + + while (*arg) + { + while (*arg == ',') + arg++; + while (arg[pos] && arg[pos] != ',') + pos++; + result = 0; + for (n = 0; exception[n] != NULL; n++) + { + if (exception[n] && strncmp (exception[n], arg, pos) == 0) + { + gfc_option.fpe |= opt_exception[n]; + arg += pos; + pos = 0; + result = 1; + break; + } + } + if (! result) + gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg); + } +} + /* Handle command-line options. Returns 0 if unrecognized, 1 if recognized and handled. */ int @@ -440,6 +477,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) gfc_handle_module_path_options (arg); break; + case OPT_ffpe_trap_: + gfc_handle_fpe_trap_option (arg); + break; + case OPT_std_f95: gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77; gfc_option.warn_std = GFC_STD_F95_OBS; |