OSDN Git Service

PR 48915 Abort handling
[pf3gnuchains/gcc-fork.git] / gcc / fortran / options.c
index 4ecb8f9..d4778ba 100644 (file)
@@ -1,5 +1,6 @@
 /* Parse and display command line options.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
@@ -26,32 +27,56 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #include "intl.h"
 #include "opts.h"
+#include "toplev.h"  /* For save_decoded_options.  */
 #include "options.h"
 #include "params.h"
 #include "tree-inline.h"
 #include "gfortran.h"
 #include "target.h"
 #include "cpp.h"
+#include "diagnostic-core.h"   /* For sorry.  */
+#include "tm.h"
 
 gfc_option_t gfc_option;
 
 
 /* Set flags that control warnings and errors for different
-   Fortran standards to their default values.  */
+   Fortran standards to their default values.  Keep in sync with
+   libgfortran/runtime/compile_options.c (init_compile_options).  */
 
 static void
 set_default_std_flags (void)
 {
   gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
     | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
-    | GFC_STD_GNU | GFC_STD_LEGACY;
+    | GFC_STD_F2008_OBS | GFC_STD_F2008_TR | GFC_STD_GNU | GFC_STD_LEGACY;
   gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
 }
 
-/* Get ready for options handling.  */
+
+/* Return language mask for Fortran options.  */
 
 unsigned int
-gfc_init_options (unsigned int argc, const char **argv)
+gfc_option_lang_mask (void)
+{
+  return CL_Fortran;
+}
+
+/* Initialize options structure OPTS.  */
+
+void
+gfc_init_options_struct (struct gcc_options *opts)
+{
+  opts->x_flag_errno_math = 0;
+  opts->x_flag_associative_math = -1;
+}
+
+/* Get ready for options handling. Keep in sync with
+   libgfortran/runtime/compile_options.c (init_compile_options). */
+
+void
+gfc_init_options (unsigned int decoded_options_count,
+                 struct cl_decoded_option *decoded_options)
 {
   gfc_source_file = NULL;
   gfc_option.module_dir = NULL;
@@ -62,15 +87,19 @@ gfc_init_options (unsigned int argc, const char **argv)
   gfc_option.max_continue_free = 255;
   gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
   gfc_option.max_subrecord_length = 0;
+  gfc_option.flag_max_array_constructor = 65535;
   gfc_option.convert = GFC_CONVERT_NATIVE;
   gfc_option.record_marker = 0;
-  gfc_option.dump_parse_tree = 0;
+  gfc_option.dump_fortran_original = 0;
+  gfc_option.dump_fortran_optimized = 0;
 
   gfc_option.warn_aliasing = 0;
   gfc_option.warn_ampersand = 0;
   gfc_option.warn_character_truncation = 0;
   gfc_option.warn_array_temp = 0;
-  gfc_option.warn_conversion = 0;
+  gfc_option.gfc_warn_conversion = 0;
+  gfc_option.warn_conversion_extra = 0;
+  gfc_option.warn_function_elimination = 0;
   gfc_option.warn_implicit_interface = 0;
   gfc_option.warn_line_truncation = 0;
   gfc_option.warn_surprising = 0;
@@ -78,6 +107,9 @@ gfc_init_options (unsigned int argc, const char **argv)
   gfc_option.warn_underflow = 1;
   gfc_option.warn_intrinsic_shadow = 0;
   gfc_option.warn_intrinsics_std = 0;
+  gfc_option.warn_align_commons = 1;
+  gfc_option.warn_real_q_constant = 0;
+  gfc_option.warn_unused_dummy_argument = 0;
   gfc_option.max_errors = 25;
 
   gfc_option.flag_all_intrinsics = 0;
@@ -86,12 +118,14 @@ gfc_init_options (unsigned int argc, const char **argv)
   gfc_option.flag_default_real = 0;
   gfc_option.flag_dollar_ok = 0;
   gfc_option.flag_underscoring = 1;
+  gfc_option.flag_whole_file = 1;
   gfc_option.flag_f2c = 0;
   gfc_option.flag_second_underscore = -1;
   gfc_option.flag_implicit_none = 0;
 
   /* Default value of flag_max_stack_var_size is set in gfc_post_options.  */
   gfc_option.flag_max_stack_var_size = -2;
+  gfc_option.flag_stack_arrays = 0;
 
   gfc_option.flag_range_check = 1;
   gfc_option.flag_pack_derived = 0;
@@ -100,15 +134,13 @@ gfc_init_options (unsigned int argc, const char **argv)
   gfc_option.flag_automatic = 1;
   gfc_option.flag_backslash = 0;
   gfc_option.flag_module_private = 0;
-  gfc_option.flag_backtrace = 0;
-  gfc_option.flag_check_array_temporaries = 0;
+  gfc_option.flag_backtrace = 1;
   gfc_option.flag_allow_leading_underscore = 0;
-  gfc_option.flag_dump_core = 0;
   gfc_option.flag_external_blas = 0;
   gfc_option.blas_matmul_limit = 30;
   gfc_option.flag_cray_pointer = 0;
   gfc_option.flag_d_lines = -1;
-  gfc_option.flag_openmp = 0;
+  gfc_option.gfc_flag_openmp = 0;
   gfc_option.flag_sign_zero = 1;
   gfc_option.flag_recursive = 0;
   gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
@@ -117,23 +149,20 @@ gfc_init_options (unsigned int argc, const char **argv)
   gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
   gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
   gfc_option.flag_init_character_value = (char)0;
+  gfc_option.flag_align_commons = 1;
+  gfc_option.flag_protect_parens = -1;
+  gfc_option.flag_realloc_lhs = -1;
+  gfc_option.flag_aggressive_function_elimination = 0;
+  gfc_option.flag_frontend_optimize = -1;
   
   gfc_option.fpe = 0;
-
-  /* Argument pointers cannot point to anything but their argument.  */
-  flag_argument_noalias = 3;
-
-  flag_errno_math = 0;
+  gfc_option.rtcheck = 0;
+  gfc_option.coarray = GFC_FCOARRAY_NONE;
 
   set_default_std_flags ();
 
-  /* -fshort-enums can be default on some targets.  */
-  gfc_option.fshort_enums = targetm.default_short_enums ();
-
   /* Initialize cpp-related options.  */
-  gfc_cpp_init_options(argc, argv);
-
-  return CL_Fortran;
+  gfc_cpp_init_options (decoded_options_count, decoded_options);
 }
 
 
@@ -222,9 +251,49 @@ gfc_post_options (const char **pfilename)
   char *source_path;
   int i;
 
-  /* Issue an error if -fwhole-program was used.  */
+  /* Excess precision other than "fast" requires front-end
+     support.  */
+  if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
+      && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
+    sorry ("-fexcess-precision=standard for Fortran");
+  flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+
+  /* Whole program needs whole file mode.  */
   if (flag_whole_program)
-    gfc_fatal_error ("Option -fwhole-program is not supported for Fortran");
+    gfc_option.flag_whole_file = 1;
+
+  /* Enable whole-file mode if LTO is in effect.  */
+  if (flag_lto)
+    gfc_option.flag_whole_file = 1;
+
+  /* Fortran allows associative math - but we cannot reassociate if
+     we want traps or signed zeros. Cf. also flag_protect_parens.  */
+  if (flag_associative_math == -1)
+    flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
+
+  if (gfc_option.flag_protect_parens == -1)
+    gfc_option.flag_protect_parens = !optimize_fast;
+
+  /* By default, disable (re)allocation during assignment for -std=f95,
+     and enable it for F2003/F2008/GNU/Legacy. */
+  if (gfc_option.flag_realloc_lhs == -1)
+    {
+      if (gfc_option.allow_std & GFC_STD_F2003)
+       gfc_option.flag_realloc_lhs = 1;
+      else
+       gfc_option.flag_realloc_lhs = 0;
+    }
+
+  /* -fbounds-check is equivalent to -fcheck=bounds */
+  if (flag_bounds_check)
+    gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
+
+  if (flag_compare_debug)
+    gfc_option.dump_fortran_original = 0;
+
+  /* Make -fmax-errors visible to gfortran's diagnostic machinery.  */
+  if (global_options_set.x_flag_max_errors)
+    gfc_option.max_errors = flag_max_errors;
 
   /* Verify the input file name.  */
   if (!filename || strcmp (filename, "-") == 0)
@@ -259,13 +328,13 @@ gfc_post_options (const char **pfilename)
       source_path = (char *) alloca (i + 1);
       memcpy (source_path, canon_source_file, i);
       source_path[i] = 0;
-      gfc_add_include_path (source_path, true);
+      gfc_add_include_path (source_path, true, true);
     }
   else
-    gfc_add_include_path (".", true);
+    gfc_add_include_path (".", true, true);
 
   if (canon_source_file != gfc_source_file)
-    gfc_free (CONST_CAST (char *, canon_source_file));
+    free (CONST_CAST (char *, canon_source_file));
 
   /* Decide which form the file will be read in as.  */
 
@@ -313,7 +382,7 @@ gfc_post_options (const char **pfilename)
                     gfc_option.flag_max_stack_var_size);
   else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
     gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
-  else if (!gfc_option.flag_automatic && gfc_option.flag_openmp)
+  else if (!gfc_option.flag_automatic && gfc_option.gfc_flag_openmp)
     gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
                     "-fopenmp");
   else if (gfc_option.flag_max_stack_var_size != -2
@@ -321,23 +390,27 @@ gfc_post_options (const char **pfilename)
     gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
                     gfc_option.flag_max_stack_var_size);
   else if (gfc_option.flag_max_stack_var_size != -2
-          && gfc_option.flag_openmp)
+          && gfc_option.gfc_flag_openmp)
     gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
                     "implied by -fopenmp", 
                     gfc_option.flag_max_stack_var_size);
 
-  /* Implied -frecursive; implemented as -fmax-stack-var-size=-1.  */
-  if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.flag_openmp)
+  /* Implement -frecursive as -fmax-stack-var-size=-1.  */
+  if (gfc_option.flag_recursive)
     gfc_option.flag_max_stack_var_size = -1;
 
+  /* Implied -frecursive; implemented as -fmax-stack-var-size=-1.  */
+  if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.gfc_flag_openmp
+      && gfc_option.flag_automatic)
+    {
+      gfc_option.flag_recursive = 1;
+      gfc_option.flag_max_stack_var_size = -1;
+    }
+
   /* Set default.  */
   if (gfc_option.flag_max_stack_var_size == -2)
     gfc_option.flag_max_stack_var_size = 32768;
 
-  /* Implement -frecursive as -fmax-stack-var-size=-1.  */
-  if (gfc_option.flag_recursive)
-    gfc_option.flag_max_stack_var_size = -1;
-
   /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
   if (!gfc_option.flag_automatic)
     gfc_option.flag_max_stack_var_size = 0;
@@ -348,6 +421,15 @@ gfc_post_options (const char **pfilename)
       gfc_option.warn_tabs = 0;
     }
 
+  if (pedantic && gfc_option.flag_whole_file)
+    gfc_option.flag_whole_file = 2;
+
+  /* Optimization implies front end optimization, unless the user
+     specified it directly.  */
+
+  if (gfc_option.flag_frontend_optimize == -1)
+    gfc_option.flag_frontend_optimize = optimize;
+
   gfc_cpp_post_options ();
 
 /* FIXME: return gfc_cpp_preprocess_only ();
@@ -368,6 +450,7 @@ set_Wall (int setting)
 {
   gfc_option.warn_aliasing = setting;
   gfc_option.warn_ampersand = setting;
+  gfc_option.gfc_warn_conversion = setting;
   gfc_option.warn_line_truncation = setting;
   gfc_option.warn_surprising = setting;
   gfc_option.warn_tabs = !setting;
@@ -375,18 +458,14 @@ set_Wall (int setting)
   gfc_option.warn_intrinsic_shadow = setting;
   gfc_option.warn_intrinsics_std = setting;
   gfc_option.warn_character_truncation = setting;
+  gfc_option.warn_real_q_constant = setting;
+  gfc_option.warn_unused_dummy_argument = setting;
 
   warn_unused = setting;
   warn_return_type = setting;
   warn_switch = setting;
-
-  /* We save the value of warn_uninitialized, since if they put
-     -Wuninitialized on the command line, we need to generate a
-     warning about not using it without also specifying -O.  */
-  if (setting == 0)
-    warn_uninitialized = 0;
-  else if (warn_uninitialized != 1)
-    warn_uninitialized = 2;
+  warn_uninitialized = setting;
+  warn_maybe_uninitialized = setting;
 }
 
 
@@ -397,11 +476,12 @@ gfc_handle_module_path_options (const char *arg)
   if (gfc_option.module_dir != NULL)
     gfc_fatal_error ("gfortran: Only one -J option allowed");
 
-  gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
+  gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
   strcpy (gfc_option.module_dir, arg);
-  strcat (gfc_option.module_dir, "/");
 
-  gfc_add_include_path (gfc_option.module_dir, true);
+  gfc_add_include_path (gfc_option.module_dir, true, false);
+
+  strcat (gfc_option.module_dir, "/");
 }
 
 
@@ -443,26 +523,77 @@ gfc_handle_fpe_trap_option (const char *arg)
 }
 
 
+static void
+gfc_handle_coarray_option (const char *arg)
+{
+  if (strcmp (arg, "none") == 0)
+    gfc_option.coarray = GFC_FCOARRAY_NONE;
+  else if (strcmp (arg, "single") == 0)
+    gfc_option.coarray = GFC_FCOARRAY_SINGLE;
+  else if (strcmp (arg, "lib") == 0)
+    gfc_option.coarray = GFC_FCOARRAY_LIB;
+  else
+    gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg);
+}
+
+
+static void
+gfc_handle_runtime_check_option (const char *arg)
+{
+  int result, pos = 0, n;
+  static const char * const optname[] = { "all", "bounds", "array-temps",
+                                         "recursion", "do", "pointer",
+                                         "mem", NULL };
+  static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
+                                GFC_RTCHECK_ARRAY_TEMPS,
+                                GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
+                                GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
+                                0 };
+  while (*arg)
+    {
+      while (*arg == ',')
+       arg++;
+
+      while (arg[pos] && arg[pos] != ',')
+       pos++;
+
+      result = 0;
+      for (n = 0; optname[n] != NULL; n++)
+       {
+         if (optname[n] && strncmp (optname[n], arg, pos) == 0)
+           {
+             gfc_option.rtcheck |= optmask[n];
+             arg += pos;
+             pos = 0;
+             result = 1;
+             break;
+           }
+       }
+      if (!result)
+       gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg);
+    }
+}
+
+
 /* Handle command-line options.  Returns 0 if unrecognized, 1 if
    recognized and handled.  */
 
-int
-gfc_handle_option (size_t scode, const char *arg, int value)
+bool
+gfc_handle_option (size_t scode, const char *arg, int value,
+                  int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
+                  const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
 {
-  int result = 1;
+  bool result = true;
   enum opt_code code = (enum opt_code) scode;
 
-  /* Ignore file names.  */
-  if (code == N_OPTS)
-    return 1;
-
   if (gfc_cpp_handle_option (scode, arg, value) == 1)
-    return 1;
+    return true;
 
   switch (code)
     {
     default:
-      result = 0;
+      result = false;
       break;
 
     case OPT_Wall:
@@ -486,13 +617,25 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_Wconversion:
-      gfc_option.warn_conversion = value;
+      gfc_option.gfc_warn_conversion = value;
+      break;
+
+    case OPT_Wconversion_extra:
+      gfc_option.warn_conversion_extra = value;
+      break;
+
+    case OPT_Wfunction_elimination:
+      gfc_option.warn_function_elimination = value;
       break;
 
     case OPT_Wimplicit_interface:
       gfc_option.warn_implicit_interface = value;
       break;
 
+    case OPT_Wimplicit_procedure:
+      gfc_option.warn_implicit_procedure = value;
+      break;
+
     case OPT_Wline_truncation:
       gfc_option.warn_line_truncation = value;
       break;
@@ -517,6 +660,18 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.warn_intrinsic_shadow = value;
       break;
 
+    case OPT_Walign_commons:
+      gfc_option.warn_align_commons = value;
+      break;
+
+    case OPT_Wreal_q_constant:
+      gfc_option.warn_real_q_constant = value;
+      break;
+
+    case OPT_Wunused_dummy_argument:
+      gfc_option.warn_unused_dummy_argument = value;
+      break;
+
     case OPT_fall_intrinsics:
       gfc_option.flag_all_intrinsics = 1;
       break;
@@ -538,13 +693,9 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
       
     case OPT_fcheck_array_temporaries:
-      gfc_option.flag_check_array_temporaries = value;
+      gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
       break;
       
-    case OPT_fdump_core:
-      gfc_option.flag_dump_core = value;
-      break;
-
     case OPT_fcray_pointer:
       gfc_option.flag_cray_pointer = value;
       break;
@@ -573,8 +724,13 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.flag_d_lines = 0;
       break;
 
+    case OPT_fdump_fortran_original:
     case OPT_fdump_parse_tree:
-      gfc_option.dump_parse_tree = value;
+      gfc_option.dump_fortran_original = value;
+      break;
+
+    case OPT_fdump_fortran_optimized:
+      gfc_option.dump_fortran_optimized = value;
       break;
 
     case OPT_ffixed_form:
@@ -596,7 +752,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fopenmp:
-      gfc_option.flag_openmp = value;
+      gfc_option.gfc_flag_openmp = value;
       break;
 
     case OPT_ffree_line_length_none:
@@ -613,6 +769,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.flag_underscoring = value;
       break;
 
+    case OPT_fwhole_file:
+      gfc_option.flag_whole_file = value;
+      break;
+
     case OPT_fsecond_underscore:
       gfc_option.flag_second_underscore = value;
       break;
@@ -629,18 +789,22 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fintrinsic_modules_path:
-      gfc_add_include_path (arg, false);
+      gfc_add_include_path (arg, false, false);
       gfc_add_intrinsic_modules_path (arg);
       break;
 
-    case OPT_fmax_errors_:
-      gfc_option.max_errors = value;
+    case OPT_fmax_array_constructor_:
+      gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
       break;
 
     case OPT_fmax_stack_var_size_:
       gfc_option.flag_max_stack_var_size = value;
       break;
 
+    case OPT_fstack_arrays:
+      gfc_option.flag_stack_arrays = value;
+      break;
+
     case OPT_fmodule_private:
       gfc_option.flag_module_private = value;
       break;
@@ -704,6 +868,8 @@ gfc_handle_option (size_t scode, const char *arg, int value)
        gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
       else if (!strcasecmp (arg, "nan"))
        gfc_option.flag_init_real = GFC_INIT_REAL_NAN;
+      else if (!strcasecmp (arg, "snan"))
+       gfc_option.flag_init_real = GFC_INIT_REAL_SNAN;
       else if (!strcasecmp (arg, "inf"))
        gfc_option.flag_init_real = GFC_INIT_REAL_INF;
       else if (!strcasecmp (arg, "-inf"))
@@ -730,7 +896,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_I:
-      gfc_add_include_path (arg, true);
+      gfc_add_include_path (arg, true, false);
       break;
 
     case OPT_J:
@@ -746,7 +912,8 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_std_f95:
-      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77;
+      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
+                            | GFC_STD_F2008_OBS;
       gfc_option.warn_std = GFC_STD_F95_OBS;
       gfc_option.max_continue_fixed = 19;
       gfc_option.max_continue_free = 39;
@@ -757,7 +924,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
 
     case OPT_std_f2003:
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
-       | GFC_STD_F2003 | GFC_STD_F95;
+       | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
       gfc_option.warn_std = GFC_STD_F95_OBS;
       gfc_option.max_identifier_length = 63;
       gfc_option.warn_ampersand = 1;
@@ -766,8 +933,18 @@ gfc_handle_option (size_t scode, const char *arg, int value)
 
     case OPT_std_f2008:
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
-       | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008;
-      gfc_option.warn_std = GFC_STD_F95_OBS;
+       | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
+      gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
+      gfc_option.max_identifier_length = 63;
+      gfc_option.warn_ampersand = 1;
+      gfc_option.warn_tabs = 0;
+      break;
+
+    case OPT_std_f2008tr:
+      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
+       | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
+       | GFC_STD_F2008_TR;
+      gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
       gfc_option.max_identifier_length = 63;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;
@@ -787,7 +964,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fshort_enums:
-      gfc_option.fshort_enums = 1;
+      /* Handled in language-independent code.  */
       break;
 
     case OPT_fconvert_little_endian:
@@ -823,9 +1000,113 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_frecursive:
-      gfc_option.flag_recursive = 1;
+      gfc_option.flag_recursive = value;
+      break;
+
+    case OPT_falign_commons:
+      gfc_option.flag_align_commons = value;
+      break;
+
+    case  OPT_faggressive_function_elimination:
+      gfc_option.flag_aggressive_function_elimination = value;
+      break;
+
+    case OPT_ffrontend_optimize:
+      gfc_option.flag_frontend_optimize = value;
+      break;
+
+    case OPT_fprotect_parens:
+      gfc_option.flag_protect_parens = value;
+      break;
+
+    case OPT_frealloc_lhs:
+      gfc_option.flag_realloc_lhs = value;
+      break;
+
+    case OPT_fcheck_:
+      gfc_handle_runtime_check_option (arg);
       break;
+
+    case OPT_fcoarray_:
+      gfc_handle_coarray_option (arg);
+      break;
+    }
+
+  return result;
+}
+
+
+/* Return a string with the options passed to the compiler; used for
+   Fortran's compiler_options() intrinsic.  */
+
+char *
+gfc_get_option_string (void)
+{
+  unsigned j;
+  size_t len, pos;
+  char *result;
+
+  /* Determine required string length.  */
+
+  len = 0;
+  for (j = 1; j < save_decoded_options_count; j++)
+    {
+      switch (save_decoded_options[j].opt_index)
+        {
+        case OPT_o:
+        case OPT_d:
+        case OPT_dumpbase:
+        case OPT_dumpdir:
+        case OPT_auxbase:
+        case OPT_quiet:
+        case OPT_version:
+        case OPT_fintrinsic_modules_path:
+          /* Ignore these.  */
+          break;
+       default:
+         /* Ignore file names. */
+         if (save_decoded_options[j].orig_option_with_args_text[0] == '-')
+           len += 1
+                + strlen (save_decoded_options[j].orig_option_with_args_text);
+        }
+    }
+
+  result = XCNEWVEC (char, len);
+
+  pos = 0; 
+  for (j = 1; j < save_decoded_options_count; j++)
+    {
+      switch (save_decoded_options[j].opt_index)
+        {
+        case OPT_o:
+        case OPT_d:
+        case OPT_dumpbase:
+        case OPT_dumpdir:
+        case OPT_auxbase:
+        case OPT_quiet:
+        case OPT_version:
+        case OPT_fintrinsic_modules_path:
+          /* Ignore these.  */
+         continue;
+
+        case OPT_cpp_:
+         /* Use "-cpp" rather than "-cpp=<temporary file>".  */
+         len = 4;
+         break;
+
+        default:
+         /* Ignore file names. */
+         if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
+           continue;
+
+         len = strlen (save_decoded_options[j].orig_option_with_args_text);
+        }
+
+      memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len);
+      pos += len;
+      result[pos++] = ' ';
     }
 
+  result[--pos] = '\0';
   return result;
 }