2014-12-12  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54687
gcc/
	* flag-types.h (gfc_init_local_real, gfc_fcoarray,
	gfc_convert): New enums; moved from fortran/.

gcc/fortran/
	* gfortran.h (gfc_option_t): Remove flags which now
	have a Var().
	(init_local_real, gfc_fcoarray): Moved to ../flag-types.h.
	* libgfortran.h (unit_convert): Add comment.
	* lang.opt (flag-aggressive_function_elimination,
	flag-align_commons, flag-all_intrinsics,
	flag-allow_leading_underscore, flag-automatic, flag-backslash,
	flag-backtrace, flag-blas_matmul_limit, flag-convert,
	flag-cray_pointer, flag-dollar_ok, flag-dump_fortran_original,
	flag-dump_fortran_optimized, flag-external_blas, flag-f2c,
	flag-implicit_none, flag-init_real, flag-max_array_constructor,
	flag-module_private, flag-pack_derived, flag-range_check,
	flag-recursive, flag-repack_arrays, flag-coarray, flag-sign_zero,
	flag-underscoring): Add Var() and, where applicable, Enum().
	* options.c (gfc_handle_coarray_option): Remove.
	(gfc_init_options, gfc_post_options, gfc_handle_fpe_option,
	gfc_handle_option): Update for *.opt changes.
	* arith.c: Update for flag-variable name changes.
	* array.c: Ditto.
	* check.c: Ditto.
	* cpp.c: Ditto.
	* decl.c: Ditto.
	* expr.c: Ditto.
	* f95-lang.c: Ditto.
	* frontend-passes.c: Ditto.
	* intrinsic.c: Ditto.
	* io.c: Ditto.
	* match.c: Ditto.
	* module.c: Ditto.
	* parse.c: Ditto.
	* primary.c: Ditto.
	* resolve.c: Ditto.
	* scanner.c: Ditto.
	* simplify.c: Ditto.
	* symbol.c: Ditto.
	* trans-array.c: Ditto.
	* trans-common.c: Ditto.
	* trans-decl.c: Ditto.
	* trans-expr.c: Ditto.
	* trans-intrinsic.c: Ditto.
	* trans-openmp.c: Ditto.
	* trans-stmt.c: Ditto.
	* trans-types.c: Ditto.
	* trans.c: Ditto.

diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 52ff7ee..81e8fb8 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -263,4 +263,38 @@ enum lto_partition_model {
   LTO_PARTITION_MAX = 4
 };
 
+
+/* gfortran -finit-real= values.  */
+
+enum gfc_init_local_real
+{
+  GFC_INIT_REAL_OFF = 0,
+  GFC_INIT_REAL_ZERO,
+  GFC_INIT_REAL_NAN,
+  GFC_INIT_REAL_SNAN,
+  GFC_INIT_REAL_INF,
+  GFC_INIT_REAL_NEG_INF
+};
+
+/* gfortran -fcoarray= values.  */
+
+enum gfc_fcoarray
+{
+  GFC_FCOARRAY_NONE = 0,
+  GFC_FCOARRAY_SINGLE,
+  GFC_FCOARRAY_LIB
+};
+
+
+/* gfortran -fconvert= values; used for unformatted I/O.
+   Keep in sync with GFC_CONVERT_* in gcc/fortran/libgfortran.h.   */
+enum gfc_convert
+{
+  GFC_FLAG_CONVERT_NATIVE = 0,
+  GFC_FLAG_CONVERT_SWAP,
+  GFC_FLAG_CONVERT_BIG,
+  GFC_FLAG_CONVERT_LITTLE
+};
+
+
 #endif /* ! GCC_FLAG_TYPES_H */
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index 6394547..e8a5efe 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -301,7 +301,7 @@ gfc_check_integer_range (mpz_t p, int kind)
     }
 
 
-  if (gfc_option.flag_range_check == 0)
+  if (flag_range_check == 0)
     return result;
 
   if (mpz_cmp (p, gfc_integer_kinds[i].min_int) < 0
@@ -333,12 +333,12 @@ gfc_check_real_range (mpfr_t p, int kind)
 
   if (mpfr_inf_p (p))
     {
-      if (gfc_option.flag_range_check != 0)
+      if (flag_range_check != 0)
 	retval = ARITH_OVERFLOW;
     }
   else if (mpfr_nan_p (p))
     {
-      if (gfc_option.flag_range_check != 0)
+      if (flag_range_check != 0)
 	retval = ARITH_NAN;
     }
   else if (mpfr_sgn (q) == 0)
@@ -348,14 +348,14 @@ gfc_check_real_range (mpfr_t p, int kind)
     }
   else if (mpfr_cmp (q, gfc_real_kinds[i].huge) > 0)
     {
-      if (gfc_option.flag_range_check == 0)
+      if (flag_range_check == 0)
 	mpfr_set_inf (p, mpfr_sgn (p));
       else
 	retval = ARITH_OVERFLOW;
     }
   else if (mpfr_cmp (q, gfc_real_kinds[i].subnormal) < 0)
     {
-      if (gfc_option.flag_range_check == 0)
+      if (flag_range_check == 0)
 	{
 	  if (mpfr_sgn (p) < 0)
 	    {
@@ -736,7 +736,7 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
       break;
 
     case BT_REAL:
-      if (mpfr_sgn (op2->value.real) == 0 && gfc_option.flag_range_check == 1)
+      if (mpfr_sgn (op2->value.real) == 0 && flag_range_check == 1)
 	{
 	  rc = ARITH_DIV0;
 	  break;
@@ -748,7 +748,7 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
 
     case BT_COMPLEX:
       if (mpc_cmp_si_si (op2->value.complex, 0, 0) == 0
-	  && gfc_option.flag_range_check == 1)
+	  && flag_range_check == 1)
 	{
 	  rc = ARITH_DIV0;
 	  break;
@@ -863,7 +863,7 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
 		    int i;
 		    i = gfc_validate_kind (BT_INTEGER, result->ts.kind, false);
 
-		    if (gfc_option.flag_range_check)
+		    if (flag_range_check)
 		      rc = ARITH_OVERFLOW;
 
 		    /* Still, we want to give the same value as the
@@ -1978,7 +1978,7 @@ gfc_int2int (gfc_expr *src, int kind)
 
   /*  If we do not trap numeric overflow, we need to convert the number to
       signed, throwing away high-order bits if necessary.  */
-  if (gfc_option.flag_range_check == 0)
+  if (flag_range_check == 0)
     {
       int k;
 
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index e27ca01..f436eb8 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "flags.h"
 #include "gfortran.h"
 #include "match.h"
 #include "constructor.h"
@@ -207,7 +208,7 @@ coarray:
 	return MATCH_ERROR;
     }
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return MATCH_ERROR;
@@ -590,7 +591,7 @@ coarray:
   if (!gfc_notify_std (GFC_STD_F2008, "Coarray declaration at %C"))
     goto cleanup;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       goto cleanup;
@@ -1654,7 +1655,7 @@ gfc_expand_constructor (gfc_expr *e, bool fatal)
 
   /* If we can successfully get an array element at the max array size then
      the array is too big to expand, so we just return.  */
-  f = gfc_get_array_element (e, gfc_option.flag_max_array_constructor);
+  f = gfc_get_array_element (e, flag_max_array_constructor);
   if (f != NULL)
     {
       gfc_free_expr (f);
@@ -1663,8 +1664,7 @@ gfc_expand_constructor (gfc_expr *e, bool fatal)
 	  gfc_error ("The number of elements in the array constructor "
 		     "at %L requires an increase of the allowed %d "
 		     "upper limit.   See %<-fmax-array-constructor%> "
-		     "option", &e->where,
-		     gfc_option.flag_max_array_constructor);
+		     "option", &e->where, flag_max_array_constructor);
 	  return false;
 	}
       return true;
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index ef40e66..681bed9 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1481,7 +1481,7 @@ check_co_collective (gfc_expr *a, gfc_expr *image_idx, gfc_expr *stat,
 	}
     }
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %L, use %<-fcoarray=%> to enable",
 		       &a->where);
@@ -2568,7 +2568,7 @@ gfc_check_lbound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
 bool
 gfc_check_lcobound (gfc_expr *coarray, gfc_expr *dim, gfc_expr *kind)
 {
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return false;
@@ -4846,7 +4846,7 @@ gfc_check_image_index (gfc_expr *coarray, gfc_expr *sub)
 {
   mpz_t nelems;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return false;
@@ -4884,7 +4884,7 @@ gfc_check_image_index (gfc_expr *coarray, gfc_expr *sub)
 bool
 gfc_check_num_images (gfc_expr *distance, gfc_expr *failed)
 {
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return false;
@@ -4926,7 +4926,7 @@ gfc_check_num_images (gfc_expr *distance, gfc_expr *failed)
 bool
 gfc_check_this_image (gfc_expr *coarray, gfc_expr *dim, gfc_expr *distance)
 {
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return false;
@@ -5125,7 +5125,7 @@ gfc_check_ubound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind)
 bool
 gfc_check_ucobound (gfc_expr *coarray, gfc_expr *dim, gfc_expr *kind)
 {
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return false;
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index 090e209..70f83ee 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -170,7 +170,7 @@ cpp_define_builtins (cpp_reader *pfile)
   cpp_define (pfile, "__GFORTRAN__=1");
   cpp_define (pfile, "_LANGUAGE_FORTRAN=1");
 
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     cpp_define (pfile, "_OPENMP=201307");
 
   /* The defines below are necessary for the TARGET_* macros.
@@ -470,7 +470,7 @@ gfc_cpp_post_options (void)
 
   cpp_option->cpp_pedantic = pedantic;
 
-  cpp_option->dollars_in_ident = gfc_option.flag_dollar_ok;
+  cpp_option->dollars_in_ident = flag_dollar_ok;
   cpp_option->discard_comments = gfc_cpp_option.discard_comments;
   cpp_option->discard_comments_in_macro_exp = gfc_cpp_option.discard_comments_in_macro_exp;
   cpp_option->print_include_names = gfc_cpp_option.print_include_names;
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index c6b46b9..da4207e 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1838,7 +1838,7 @@ variable_decl (int elem)
       goto cleanup;
     }
 
-  if (gfc_option.flag_cray_pointer)
+  if (flag_cray_pointer)
     cp_as = gfc_copy_array_spec (as);
 
   /* At this point, we know for sure if the symbol is PARAMETER and can thus
@@ -1907,7 +1907,7 @@ variable_decl (int elem)
   /*  If this symbol has already shown up in a Cray Pointer declaration,
       and this is not a component declaration,
       then we want to set the type & bail out.  */
-  if (gfc_option.flag_cray_pointer && gfc_current_state () != COMP_DERIVED)
+  if (flag_cray_pointer && gfc_current_state () != COMP_DERIVED)
     {
       gfc_find_symbol (name, gfc_current_ns, 1, &sym);
       if (sym != NULL && sym->attr.cray_pointee)
@@ -6755,7 +6755,7 @@ gfc_match_pointer (void)
   gfc_gobble_whitespace ();
   if (gfc_peek_ascii_char () == '(')
     {
-      if (!gfc_option.flag_cray_pointer)
+      if (!flag_cray_pointer)
 	{
 	  gfc_error ("Cray pointer declaration at %C requires -fcray-pointer "
 		     "flag");
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index bfe8356..302bff2 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1529,13 +1529,12 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
 	}
 
       limit = mpz_get_ui (ptr);
-      if (limit >= gfc_option.flag_max_array_constructor)
+      if (limit >= flag_max_array_constructor)
         {
 	  gfc_error ("The number of elements in the array constructor "
 		     "at %L requires an increase of the allowed %d "
 		     "upper limit.   See -fmax-array-constructor "
-		     "option", &expr->where,
-		     gfc_option.flag_max_array_constructor);
+		     "option", &expr->where, flag_max_array_constructor);
 	  return false;
 	}
 
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 223e938..1054230 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -1139,9 +1139,7 @@ gfc_init_builtin_functions (void)
 #include "../sync-builtins.def"
 #undef DEF_SYNC_BUILTIN
 
-  if (gfc_option.gfc_flag_openmp
-      || gfc_option.gfc_flag_openmp_simd
-      || flag_tree_parallelize_loops)
+  if (flag_openmp || flag_openmp_simd || flag_tree_parallelize_loops)
     {
 #undef DEF_GOMP_BUILTIN
 #define DEF_GOMP_BUILTIN(code, name, type, attr) \
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 5485cd1..02f8e89 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -108,7 +108,7 @@ gfc_run_passes (gfc_namespace *ns)
     {
       optimize_namespace (ns);
       optimize_reduction (ns);
-      if (gfc_option.dump_fortran_optimized)
+      if (flag_dump_fortran_optimized)
 	gfc_dump_parse_tree (ns, stdout);
 
       expr_array.release ();
@@ -389,7 +389,7 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
 
       /* Only eliminate potentially impure functions if the
 	 user specifically requested it.  */
-      if (!gfc_option.flag_aggressive_function_elimination
+      if (!flag_aggressive_function_elimination
 	  && !(*e)->value.function.esym->attr.pure
 	  && !(*e)->value.function.esym->attr.implicit_pure)
 	return 0;
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 9d96b85..63e4671 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -599,18 +599,6 @@ enum gfc_isym_id
 };
 typedef enum gfc_isym_id gfc_isym_id;
 
-
-typedef enum
-{
-  GFC_INIT_REAL_OFF = 0,
-  GFC_INIT_REAL_ZERO,
-  GFC_INIT_REAL_NAN,
-  GFC_INIT_REAL_SNAN,
-  GFC_INIT_REAL_INF,
-  GFC_INIT_REAL_NEG_INF
-}
-init_local_real;
-
 typedef enum
 {
   GFC_INIT_LOGICAL_OFF = 0,
@@ -635,14 +623,6 @@ init_local_integer;
 
 typedef enum
 {
-  GFC_FCOARRAY_NONE = 0,
-  GFC_FCOARRAY_SINGLE,
-  GFC_FCOARRAY_LIB
-}
-gfc_fcoarray;
-
-typedef enum
-{
   GFC_ENABLE_REVERSE,
   GFC_FORWARD_SET,
   GFC_REVERSE_SET,
@@ -2439,64 +2419,36 @@ typedef struct
   int max_continue_fixed;
   int max_continue_free;
   int max_identifier_length;
-  int dump_fortran_original;
-  int dump_fortran_optimized;
 
   int max_errors;
 
-  int flag_all_intrinsics;
   int flag_default_double;
   int flag_default_integer;
   int flag_default_real;
   int flag_integer4_kind;
   int flag_real4_kind;
   int flag_real8_kind;
-  int flag_dollar_ok;
-  int flag_underscoring;
   int flag_second_underscore;
-  int flag_implicit_none;
   int flag_max_stack_var_size;
-  int flag_max_array_constructor;
-  int flag_range_check;
-  int flag_pack_derived;
-  int flag_repack_arrays;
   int flag_preprocessed;
-  int flag_f2c;
-  int flag_automatic;
-  int flag_backslash;
-  int flag_backtrace;
-  int flag_allow_leading_underscore;
-  int flag_external_blas;
-  int blas_matmul_limit;
-  int flag_cray_pointer;
   int flag_d_lines;
-  int gfc_flag_openmp;
-  int gfc_flag_openmp_simd;
-  int flag_sign_zero;
   int flag_stack_arrays;
-  int flag_module_private;
-  int flag_recursive;
   int flag_init_local_zero;
   int flag_init_integer;
   int flag_init_integer_value;
-  int flag_init_real;
   int flag_init_logical;
   int flag_init_character;
   char flag_init_character_value;
-  int flag_align_commons;
   int flag_protect_parens;
   int flag_realloc_lhs;
-  int flag_aggressive_function_elimination;
   int flag_frontend_optimize;
 
   int fpe;
   int fpe_summary;
   int rtcheck;
-  gfc_fcoarray coarray;
 
   int warn_std;
   int allow_std;
-  int convert;
   int record_marker;
   int max_subrecord_length;
 }
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 5abd02d..22fa9db 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -4264,7 +4264,7 @@ gfc_check_intrinsic_standard (const gfc_intrinsic_sym* isym,
   const char* symstd_msg;
 
   /* For -fall-intrinsics, just succeed.  */
-  if (gfc_option.flag_all_intrinsics)
+  if (flag_all_intrinsics)
     return true;
 
   /* Find the symbol's standard message for later usage.  */
@@ -4623,8 +4623,7 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag)
     }
   else if (wflag)
     {
-      if (gfc_option.flag_range_check
-	  && expr->expr_type == EXPR_CONSTANT
+      if (flag_range_check && expr->expr_type == EXPR_CONSTANT
 	  && from_ts.type == ts->type)
 	{
 	  /* Do nothing. Constants of the same type are range-checked
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index de8254a..ecbc120 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -157,7 +157,7 @@ next_char (gfc_instring in_string)
 	c = '\0';
     }
 
-  if (gfc_option.flag_backslash && c == '\\')
+  if (flag_backslash && c == '\\')
     {
       locus old_locus = gfc_current_locus;
 
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index c297817..a5f43d1 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -346,59 +346,62 @@ Fortran Joined
 ; Documented in common.opt
 
 faggressive-function-elimination
-Fortran
+Fortran Var(flag_aggressive_function_elimination)
 Eliminate multiple function invokations also for impure functions
 
 falign-commons
-Fortran
+Fortran Var(flag_align_commons) Init(1)
 Enable alignment of COMMON blocks
 
 fall-intrinsics
-Fortran RejectNegative
+Fortran RejectNegative Var(flag_all_intrinsics)
 All intrinsics procedures are available regardless of selected standard
 
 fallow-leading-underscore
-Fortran Undocumented
+Fortran Undocumented Var(flag_allow_leading_underscore)
 ; For internal use only: allow the first character of symbol names to be an underscore
 
 fautomatic
-Fortran
+Fortran Var(flag_automatic) Init(1)
 Do not treat local variables and COMMON blocks as if they were named in SAVE statements
 
 fbackslash
-Fortran
+Fortran Var(flag_backslash)
 Specify that backslash in string introduces an escape character
 
 fbacktrace
-Fortran
+Fortran Var(flag_backtrace) Init(1)
 Produce a backtrace when a runtime error is encountered
 
 fblas-matmul-limit=
-Fortran RejectNegative Joined UInteger
+Fortran RejectNegative Joined UInteger Var(flag_blas_matmul_limit) Init(30)
 -fblas-matmul-limit=<n>	Size of the smallest matrix for which matmul will use BLAS
 
 fcheck-array-temporaries
 Fortran
 Produce a warning at runtime if a array temporary has been created for a procedure argument
 
-fconvert=big-endian
-Fortran RejectNegative
-Use big-endian format for unformatted files
+fconvert=
+Fortran RejectNegative Joined Enum(gfc_convert) Var(flag_convert) Init(GFC_FLAG_CONVERT_NATIVE)
+-fconvert=<big-endian|little-endian|native|swap> The endianness used for unformatted files.
 
-fconvert=little-endian
-Fortran RejectNegative
-Use little-endian format for unformatted files
+Enum
+Name(gfc_convert) Type(enum gfc_convert) UnknownError(Unrecognized option to endianess value: %qs)
 
-fconvert=native
-Fortran RejectNegative
-Use native format for unformatted files
+EnumValue
+Enum(gfc_convert) String(big-endian) Value(GFC_FLAG_CONVERT_BIG)
 
-fconvert=swap
-Fortran RejectNegative
-Swap endianness for unformatted files
+EnumValue
+Enum(gfc_convert) String(little-endian) Value(GFC_FLAG_CONVERT_LITTLE)
+
+EnumValue
+Enum(gfc_convert) String(native) Value(GFC_FLAG_CONVERT_NATIVE)
+
+EnumValue
+Enum(gfc_convert) String(swap) Value(GFC_FLAG_CONVERT_SWAP)
 
 fcray-pointer
-Fortran
+Fortran Var(flag_cray_pointer)
 Use the Cray Pointer extension
 
 fd-lines-as-code
@@ -422,7 +425,7 @@ Fortran
 Set the default real kind to an 8 byte wide type
 
 fdollar-ok
-Fortran
+Fortran Var(flag_dollar_ok)
 Allow dollar signs in entity names
 
 fdump-core
@@ -430,23 +433,23 @@ Fortran Ignore
 Does nothing. Preserved for backward compatibility.
 
 fdump-fortran-original
-Fortran
+Fortran Var(flag_dump_fortran_original)
 Display the code tree after parsing
 
 fdump-fortran-optimized
-Fortran
+Fortran Var(flag_dump_fortran_optimized)
 Display the code tree after front end optimization
 
 fdump-parse-tree
-Fortran
+Fortran Alias(fdump-fortran-original)
 Display the code tree after parsing; deprecated option
 
 fexternal-blas
-Fortran
+Fortran Var(flag_external_blas)
 Specify that an external BLAS library should be used for matmul calls on large-size arrays
 
 ff2c
-Fortran
+Fortran Var(flag_f2c)
 Use f2c calling convention
 
 ffixed-form
@@ -498,7 +501,7 @@ Fortran
 Enable front end optimization
 
 fimplicit-none
-Fortran
+Fortran Var(flag_implicit_none)
 Specify that no implicit typing is allowed, unless overridden by explicit IMPLICIT statements
 
 finit-character=
@@ -518,11 +521,29 @@ Fortran RejectNegative Joined
 -finit-logical=<true|false>	Initialize local logical variables
 
 finit-real=
-Fortran RejectNegative Joined
--finit-real=<zero|nan|inf|-inf>	Initialize local real variables
+Fortran RejectNegative Joined Enum(gfc_init_local_real) Var(flag_init_real) Init(GFC_INIT_REAL_OFF)
+-finit-real=<zero|snan|nan|inf|-inf>	Initialize local real variables
+
+Enum
+Name(gfc_init_local_real) Type(enum gfc_init_local_real) UnknownError(Unrecognized option to floating-point init value: %qs)
+
+EnumValue
+Enum(gfc_init_local_real) String(zero) Value(GFC_INIT_REAL_ZERO)
+
+EnumValue
+Enum(gfc_init_local_real) String(snan) Value(GFC_INIT_REAL_SNAN)
+
+EnumValue
+Enum(gfc_init_local_real) String(nan) Value(GFC_INIT_REAL_NAN)
+
+EnumValue
+Enum(gfc_init_local_real) String(inf) Value(GFC_INIT_REAL_INF)
+
+EnumValue
+Enum(gfc_init_local_real) String(-inf) Value(GFC_INIT_REAL_NEG_INF)
 
 fmax-array-constructor=
-Fortran RejectNegative Joined UInteger
+Fortran RejectNegative Joined UInteger Var(flag_max_array_constructor) Init(65535)
 -fmax-array-constructor=<n>	Maximum number of objects in an array constructor
 
 fmax-identifier-length=
@@ -542,7 +563,7 @@ Fortran
 Put all local arrays on stack.
 
 fmodule-private
-Fortran
+Fortran Var(flag_module_private)
 Set default accessibility of module entities to PRIVATE.
 
 fopenmp
@@ -554,7 +575,7 @@ Fortran
 ; Documented in C
 
 fpack-derived
-Fortran
+Fortran Var(flag_pack_derived)
 Try to lay out derived types as compactly as possible
 
 fpreprocessed
@@ -566,7 +587,7 @@ Fortran
 Protect parentheses in expressions
 
 frange-check
-Fortran
+Fortran Var(flag_range_check) Init(1)
 Enable range checking during compilation
 
 freal-4-real-8
@@ -606,16 +627,28 @@ Fortran RejectNegative
 Use an 8-byte record marker for unformatted files
 
 frecursive
-Fortran
+Fortran Var(flag_recursive)
 Allocate local variables on the stack to allow indirect recursion
 
 frepack-arrays
-Fortran
+Fortran Var(flag_repack_arrays)
 Copy array sections into a contiguous block on procedure entry
 
 fcoarray=
-Fortran RejectNegative JoinedOrMissing
--fcoarray=[...]	Specify which coarray parallelization should be used
+Fortran RejectNegative Joined Enum(gfc_fcoarray) Var(flag_coarray) Init(GFC_FCOARRAY_NONE)
+-fcoarray=<none|single|lib>	Specify which coarray parallelization should be used
+
+Enum
+Name(gfc_fcoarray) Type(enum gfc_fcoarray) UnknownError(Unrecognized option: %qs)
+
+EnumValue
+Enum(gfc_fcoarray) String(none) Value(GFC_FCOARRAY_NONE)
+
+EnumValue
+Enum(gfc_fcoarray) String(single) Value(GFC_FCOARRAY_SINGLE)
+
+EnumValue
+Enum(gfc_fcoarray) String(lib) Value(GFC_FCOARRAY_LIB)
 
 fcheck=
 Fortran RejectNegative JoinedOrMissing
@@ -630,11 +663,11 @@ Fortran Var(flag_short_enums)
 ; Documented in C
 
 fsign-zero
-Fortran
+Fortran Var(flag_sign_zero) Init(1)
 Apply negative sign to zero values
 
 funderscoring
-Fortran
+Fortran Var(flag_underscoring) Init(1)
 Append underscores to externally visible names
 
 fwhole-file
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index dda755b..e8ac926 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 
 
 /* Possible values for the CONVERT I/O specifier.  */
+/* Keep in sync with GFC_FLAG_CONVERT_* in gcc/flags.h.  */
 typedef enum
 {
   GFC_CONVERT_NONE = -1,
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index e322608..59b59ba 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -530,7 +530,7 @@ gfc_match_name (char *buffer)
   gfc_gobble_whitespace ();
 
   c = gfc_next_ascii_char ();
-  if (!(ISALPHA (c) || (c == '_' && gfc_option.flag_allow_leading_underscore)))
+  if (!(ISALPHA (c) || (c == '_' && flag_allow_leading_underscore)))
     {
       if (!gfc_error_flag_test () && c != '(')
 	gfc_error ("Invalid character in name at %C");
@@ -553,9 +553,9 @@ gfc_match_name (char *buffer)
       old_loc = gfc_current_locus;
       c = gfc_next_ascii_char ();
     }
-  while (ISALNUM (c) || c == '_' || (gfc_option.flag_dollar_ok && c == '$'));
+  while (ISALNUM (c) || c == '_' || (flag_dollar_ok && c == '$'));
 
-  if (c == '$' && !gfc_option.flag_dollar_ok)
+  if (c == '$' && !flag_dollar_ok)
     {
       gfc_fatal_error ("Invalid character %<$%> at %L. Use %<-fdollar-ok%> to "
 		       "allow it as an extension", &old_loc);
@@ -1663,7 +1663,7 @@ gfc_match_critical (void)
   if (!gfc_notify_std (GFC_STD_F2008, "CRITICAL statement at %C"))
     return MATCH_ERROR;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
        gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to "
 			"enable");
@@ -2725,7 +2725,7 @@ lock_unlock_statement (gfc_statement st)
 
   gfc_unset_implicit_pure (NULL);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
        gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
        return MATCH_ERROR;
@@ -2921,7 +2921,7 @@ sync_statement (gfc_statement st)
   if (!gfc_notify_std (GFC_STD_F2008, "SYNC statement at %C"))
     return MATCH_ERROR;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
        gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to "
 			"enable");
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 3adbe1a..0f73b0f 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -5249,7 +5249,7 @@ check_access (gfc_access specific_access, gfc_access default_access)
   if (specific_access == ACCESS_PRIVATE)
     return FALSE;
 
-  if (gfc_option.flag_module_private)
+  if (flag_module_private)
     return default_access == ACCESS_PUBLIC;
   else
     return default_access != ACCESS_PRIVATE;
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index af71ded..b0adb1b 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -87,57 +87,31 @@ gfc_init_options (unsigned int decoded_options_count,
   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_fortran_original = 0;
-  gfc_option.dump_fortran_optimized = 0;
 
   gfc_option.max_errors = 25;
 
-  gfc_option.flag_all_intrinsics = 0;
   gfc_option.flag_default_double = 0;
   gfc_option.flag_default_integer = 0;
   gfc_option.flag_default_real = 0;
   gfc_option.flag_integer4_kind = 0;
   gfc_option.flag_real4_kind = 0;
   gfc_option.flag_real8_kind = 0;
-  gfc_option.flag_dollar_ok = 0;
-  gfc_option.flag_underscoring = 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 = -1;
 
-  gfc_option.flag_range_check = 1;
-  gfc_option.flag_pack_derived = 0;
-  gfc_option.flag_repack_arrays = 0;
   gfc_option.flag_preprocessed = 0;
-  gfc_option.flag_automatic = 1;
-  gfc_option.flag_backslash = 0;
-  gfc_option.flag_module_private = 0;
-  gfc_option.flag_backtrace = 1;
-  gfc_option.flag_allow_leading_underscore = 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.gfc_flag_openmp = 0;
-  gfc_option.flag_sign_zero = 1;
-  gfc_option.flag_recursive = 0;
   gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
   gfc_option.flag_init_integer_value = 0;
-  gfc_option.flag_init_real = GFC_INIT_REAL_OFF;
   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;
@@ -146,7 +120,6 @@ gfc_init_options (unsigned int decoded_options_count,
 			   | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
 			   | GFC_FPE_UNDERFLOW;
   gfc_option.rtcheck = 0;
-  gfc_option.coarray = GFC_FCOARRAY_NONE;
 
   /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
      enabled by default in Fortran.  Ideally, we should express this
@@ -280,7 +253,7 @@ gfc_post_options (const char **pfilename)
     gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
 
   if (flag_compare_debug)
-    gfc_option.dump_fortran_original = 0;
+    flag_dump_fortran_original = 0;
 
   /* Make -fmax-errors visible to gfortran's diagnostic machinery.  */
   if (global_options_set.x_flag_max_errors)
@@ -365,36 +338,34 @@ gfc_post_options (const char **pfilename)
      use it if we're trying to be compatible with f2c, and not
      otherwise.  */
   if (gfc_option.flag_second_underscore == -1)
-    gfc_option.flag_second_underscore = gfc_option.flag_f2c;
+    gfc_option.flag_second_underscore = flag_f2c;
 
-  if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2
+  if (!flag_automatic && gfc_option.flag_max_stack_var_size != -2
       && gfc_option.flag_max_stack_var_size != 0)
     gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
 		       gfc_option.flag_max_stack_var_size);
-  else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
+  else if (!flag_automatic && flag_recursive)
     gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%>");
-  else if (!gfc_option.flag_automatic && gfc_option.gfc_flag_openmp)
+  else if (!flag_automatic && flag_openmp)
     gfc_warning_now ("Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
 		       "%<-fopenmp%>");
-  else if (gfc_option.flag_max_stack_var_size != -2
-	   && gfc_option.flag_recursive)
+  else if (gfc_option.flag_max_stack_var_size != -2 && flag_recursive)
     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.gfc_flag_openmp)
+  else if (gfc_option.flag_max_stack_var_size != -2 && flag_openmp)
     gfc_warning_now ("Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
 		       "implied by %<-fopenmp%>", 
 		     gfc_option.flag_max_stack_var_size);
 
   /* Implement -frecursive as -fmax-stack-var-size=-1.  */
-  if (gfc_option.flag_recursive)
+  if (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)
+  if (gfc_option.flag_max_stack_var_size == -2 && flag_openmp
+      && flag_automatic)
     {
-      gfc_option.flag_recursive = 1;
+      flag_recursive = 1;
       gfc_option.flag_max_stack_var_size = -1;
     }
 
@@ -403,7 +374,7 @@ gfc_post_options (const char **pfilename)
     gfc_option.flag_max_stack_var_size = 32768;
 
   /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
-  if (!gfc_option.flag_automatic)
+  if (!flag_automatic)
     gfc_option.flag_max_stack_var_size = 0;
   
   /* Optimization implies front end optimization, unless the user
@@ -412,6 +383,9 @@ gfc_post_options (const char **pfilename)
   if (gfc_option.flag_frontend_optimize == -1)
     gfc_option.flag_frontend_optimize = optimize;
 
+  if (flag_max_array_constructor > 65535)
+    flag_max_array_constructor = 65535;
+
   gfc_cpp_post_options ();
 
   return gfc_cpp_preprocess_only ();
@@ -504,20 +478,6 @@ gfc_handle_fpe_option (const char *arg, bool trap)
 
 
 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;
@@ -578,50 +538,10 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       result = false;
       break;
 
-    case OPT_fall_intrinsics:
-      gfc_option.flag_all_intrinsics = 1;
-      break;
-
-    case OPT_fautomatic:
-      gfc_option.flag_automatic = value;
-      break;
-
-    case OPT_fallow_leading_underscore:
-      gfc_option.flag_allow_leading_underscore = value;
-      break;
-      
-    case OPT_fbackslash:
-      gfc_option.flag_backslash = value;
-      break;
-      
-    case OPT_fbacktrace:
-      gfc_option.flag_backtrace = value;
-      break;
-      
     case OPT_fcheck_array_temporaries:
       gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
       break;
       
-    case OPT_fcray_pointer:
-      gfc_option.flag_cray_pointer = value;
-      break;
-
-    case OPT_ff2c:
-      gfc_option.flag_f2c = value;
-      break;
-
-    case OPT_fdollar_ok:
-      gfc_option.flag_dollar_ok = value;
-      break;
-
-    case OPT_fexternal_blas:
-      gfc_option.flag_external_blas = value;
-      break;
-
-    case OPT_fblas_matmul_limit_:
-      gfc_option.blas_matmul_limit = value;
-      break;
-
     case OPT_fd_lines_as_code:
       gfc_option.flag_d_lines = 1;
       break;
@@ -630,15 +550,6 @@ 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_fortran_original = value;
-      break;
-
-    case OPT_fdump_fortran_optimized:
-      gfc_option.dump_fortran_optimized = value;
-      break;
-
     case OPT_ffixed_form:
       gfc_option.source_form = FORM_FIXED;
       break;
@@ -657,14 +568,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_option.source_form = FORM_FREE;
       break;
 
-    case OPT_fopenmp:
-      gfc_option.gfc_flag_openmp = value;
-      break;
-
-    case OPT_fopenmp_simd:
-      gfc_option.gfc_flag_openmp_simd = value;
-      break;
-
     case OPT_ffree_line_length_none:
       gfc_option.free_line_length = 0;
       break;
@@ -675,10 +578,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_option.free_line_length = value;
       break;
 
-    case OPT_funderscoring:
-      gfc_option.flag_underscoring = value;
-      break;
-
     case OPT_fsecond_underscore:
       gfc_option.flag_second_underscore = value;
       break;
@@ -690,10 +589,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
 #endif
       break;
 
-    case OPT_fimplicit_none:
-      gfc_option.flag_implicit_none = value;
-      break;
-
     case OPT_fintrinsic_modules_path:
     case OPT_fintrinsic_modules_path_:
 
@@ -706,10 +601,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_add_intrinsic_modules_path (arg);
       break;
 
-    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;
@@ -718,22 +609,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_option.flag_stack_arrays = value;
       break;
 
-    case OPT_fmodule_private:
-      gfc_option.flag_module_private = value;
-      break;
-      
-    case OPT_frange_check:
-      gfc_option.flag_range_check = value;
-      break;
-
-    case OPT_fpack_derived:
-      gfc_option.flag_pack_derived = value;
-      break;
-
-    case OPT_frepack_arrays:
-      gfc_option.flag_repack_arrays = value;
-      break;
-
     case OPT_fpreprocessed:
       gfc_option.flag_preprocessed = value;
       break;
@@ -788,7 +663,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
     case OPT_finit_local_zero:
       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
       gfc_option.flag_init_integer_value = 0;
-      gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
       gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
       gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
       gfc_option.flag_init_character_value = (char)0;
@@ -804,22 +678,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
 			 arg);
       break;
 
-    case OPT_finit_real_:
-      if (!strcasecmp (arg, "zero"))
-	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"))
-	gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF;
-      else
-	gfc_fatal_error ("Unrecognized option to %<-finit-real%>: %s",
-			 arg);
-      break;
-
     case OPT_finit_integer_:
       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
       gfc_option.flag_init_integer_value = atoi (arg);
@@ -844,10 +702,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_handle_module_path_options (arg);
       break;
 
-    case OPT_fsign_zero:
-      gfc_option.flag_sign_zero = value;
-      break;
-
     case OPT_ffpe_trap_:
       gfc_handle_fpe_option (arg, true);
       break;
@@ -908,22 +762,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       /* Handled in language-independent code.  */
       break;
 
-    case OPT_fconvert_little_endian:
-      gfc_option.convert = GFC_CONVERT_LITTLE;
-      break;
-
-    case OPT_fconvert_big_endian:
-      gfc_option.convert = GFC_CONVERT_BIG;
-      break;
-
-    case OPT_fconvert_native:
-      gfc_option.convert = GFC_CONVERT_NATIVE;
-      break;
-
-    case OPT_fconvert_swap:
-      gfc_option.convert = GFC_CONVERT_SWAP;
-      break;
-
     case OPT_frecord_marker_4:
       gfc_option.record_marker = 4;
       break;
@@ -940,18 +778,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_option.max_subrecord_length = value;
       break;
 
-    case OPT_frecursive:
-      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;
@@ -967,10 +793,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
     case OPT_fcheck_:
       gfc_handle_runtime_check_option (arg);
       break;
-
-    case OPT_fcoarray_:
-      gfc_handle_coarray_option (arg);
-      break;
     }
 
   Fortran_handle_option_auto (&global_options, &global_options_set, 
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 970815e..8a40c2a 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include <setjmp.h>
 #include "coretypes.h"
+#include "flags.h"
 #include "gfortran.h"
 #include "match.h"
 #include "parse.h"
@@ -573,7 +574,7 @@ decode_statement (void)
 /* Like match, but don't match anything if not -fopenmp.  */
 #define matcho(keyword, subr, st)				\
     do {							\
-      if (!gfc_option.gfc_flag_openmp)				\
+      if (!flag_openmp)						\
 	;							\
       else if (match_word (keyword, subr, &old_locus)		\
 	       == MATCH_YES)					\
@@ -768,7 +769,7 @@ decode_omp_directive (void)
      not -fopenmp and simd_matched is false, i.e. if a directive other
      than one marked with match has been seen.  */
 
-  if (gfc_option.gfc_flag_openmp || simd_matched)
+  if (flag_openmp || simd_matched)
     {
       if (!gfc_error_check ())
 	gfc_error_now ("Unclassifiable OpenMP directive at %C");
@@ -895,9 +896,7 @@ next_free (void)
 	  return decode_gcc_attribute ();
 
 	}
-      else if (c == '$'
-	       && (gfc_option.gfc_flag_openmp
-		   || gfc_option.gfc_flag_openmp_simd))
+      else if (c == '$' && (flag_openmp || flag_openmp_simd))
 	{
 	  int i;
 
@@ -987,8 +986,7 @@ next_fixed (void)
 	      return decode_gcc_attribute ();
 	    }
 	  else if (c == '$'
-		   && (gfc_option.gfc_flag_openmp
-		       || gfc_option.gfc_flag_openmp_simd))
+		   && (flag_openmp || flag_openmp_simd))
 	    {
 	      for (i = 0; i < 4; i++, c = gfc_next_char_literal (NONSTRING))
 		gcc_assert ((char) gfc_wide_tolower (c) == "$omp"[i]);
@@ -5081,7 +5079,7 @@ loop:
   gfc_resolve (gfc_current_ns);
 
   /* Dump the parse tree if requested.  */
-  if (gfc_option.dump_fortran_original)
+  if (flag_dump_fortran_original)
     gfc_dump_parse_tree (gfc_current_ns, stdout);
 
   gfc_get_errors (NULL, &errors);
@@ -5128,7 +5126,7 @@ prog_units:
 
   /* Do the parse tree dump.  */ 
   gfc_current_ns
-	= gfc_option.dump_fortran_original ? gfc_global_ns_list : NULL;
+	= flag_dump_fortran_original ? gfc_global_ns_list : NULL;
 
   for (; gfc_current_ns; gfc_current_ns = gfc_current_ns->sibling)
     if (!gfc_current_ns->proc_name
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index a9bf658..47cf1ef 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -857,7 +857,7 @@ next_string_char (gfc_char_t delimiter, int *ret)
       return 0;
     }
 
-  if (gfc_option.flag_backslash && c == '\\')
+  if (flag_backslash && c == '\\')
     {
       old_locus = gfc_current_locus;
 
@@ -929,7 +929,7 @@ match_charkind_name (char *name)
 
       if (!ISALNUM (c)
 	  && c != '_'
-	  && (c != '$' || !gfc_option.flag_dollar_ok))
+	  && (c != '$' || !flag_dollar_ok))
 	break;
 
       *name++ = c;
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 3270943..a8e9cc8 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1558,7 +1558,7 @@ is_illegal_recursion (gfc_symbol* sym, gfc_namespace* context)
     proc_sym = sym;
 
   /* If sym is RECURSIVE, all is well of course.  */
-  if (proc_sym->attr.recursive || gfc_option.flag_recursive)
+  if (proc_sym->attr.recursive || flag_recursive)
     return false;
 
   /* Find the context procedure's "real" symbol if it has entries.
@@ -5058,7 +5058,7 @@ resolve_procedure:
   if (t)
     expression_rank (e);
 
-  if (t && gfc_option.coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
+  if (t && flag_coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
     add_caf_get_intrinsic (e);
 
   return t;
@@ -8483,7 +8483,7 @@ resolve_critical (gfc_code *code)
   char name[GFC_MAX_SYMBOL_LEN];
   static int serial = 0;
 
-  if (gfc_option.coarray != GFC_FCOARRAY_LIB)
+  if (flag_coarray != GFC_FCOARRAY_LIB)
     return;
 
   symtree = gfc_find_symtree (gfc_current_ns->sym_root,
@@ -9355,7 +9355,7 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
      the LHS is (re)allocatable or has a vector subscript.  If the LHS is a
      noncoindexed array and the RHS is a coindexed scalar, use the normal code
      path.  */
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (flag_coarray == GFC_FCOARRAY_LIB
       && (lhs_coindexed
 	  || (code->expr2->expr_type == EXPR_FUNCTION
 	      && code->expr2->value.function.isym
@@ -10646,7 +10646,7 @@ build_default_init_expr (gfc_symbol *sym)
       break;
 
     case BT_REAL:
-      switch (gfc_option.flag_init_real)
+      switch (flag_init_real)
 	{
 	case GFC_INIT_REAL_SNAN:
 	  init_expr->is_snan = 1;
@@ -10675,7 +10675,7 @@ build_default_init_expr (gfc_symbol *sym)
       break;
 
     case BT_COMPLEX:
-      switch (gfc_option.flag_init_real)
+      switch (flag_init_real)
 	{
 	case GFC_INIT_REAL_SNAN:
 	  init_expr->is_snan = 1;
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 6a37036..deeb594 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -749,8 +749,7 @@ skip_free_comments (void)
 	     2) handle OpenMP conditional compilation, where
 		!$ should be treated as 2 spaces (for initial lines
 		only if followed by space).  */
-	  if ((gfc_option.gfc_flag_openmp
-	       || gfc_option.gfc_flag_openmp_simd) && at_bol)
+	  if ((flag_openmp || flag_openmp_simd) && at_bol)
 	    {
 	      locus old_loc = gfc_current_locus;
 	      if (next_char () == '$')
@@ -876,7 +875,7 @@ skip_fixed_comments (void)
 	      && continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
 	    continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
 
-	  if (gfc_option.gfc_flag_openmp || gfc_option.gfc_flag_openmp_simd)
+	  if (flag_openmp || flag_openmp_simd)
 	    {
 	      if (next_char () == '$')
 		{
@@ -1822,7 +1821,7 @@ include_line (gfc_char_t *line)
 
   c = line;
 
-  if (gfc_option.gfc_flag_openmp || gfc_option.gfc_flag_openmp_simd)
+  if (flag_openmp || flag_openmp_simd)
     {
       if (gfc_current_form == FORM_FREE)
 	{
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 095de6b..cef2911 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -153,7 +153,7 @@ convert_mpz_to_unsigned (mpz_t x, int bitsize)
     {
       /* Confirm that no bits above the signed range are unset if we
 	 are doing range checking.  */
-      if (gfc_option.flag_range_check != 0)
+      if (flag_range_check != 0)
 	gcc_assert (mpz_scan0 (x, bitsize-1) == ULONG_MAX);
 
       mpz_init_set_ui (mask, 1);
@@ -184,7 +184,7 @@ gfc_convert_mpz_to_signed (mpz_t x, int bitsize)
 
   /* Confirm that no bits above the unsigned range are set if we are
      doing range checking.  */
-  if (gfc_option.flag_range_check != 0)
+  if (flag_range_check != 0)
     gcc_assert (mpz_scan1 (x, bitsize) == ULONG_MAX);
 
   if (mpz_tstbit (x, bitsize - 1) == 1)
@@ -1261,7 +1261,7 @@ gfc_simplify_bessel_n2 (gfc_expr *order1, gfc_expr *order2, gfc_expr *x,
 
   if (mpfr_cmp_ui (x->value.real, 0.0) == 0)
     {
-      if (!jn && gfc_option.flag_range_check)
+      if (!jn && flag_range_check)
 	{
 	  gfc_error ("Result of BESSEL_YN is -INF at %L", &result->where);
  	  gfc_free_expr (result);
@@ -1367,7 +1367,7 @@ gfc_simplify_bessel_n2 (gfc_expr *order1, gfc_expr *order2, gfc_expr *x,
 
       /* Special case: For YN, if the previous N gave -INF, set
 	 also N+1 to -INF.  */
-      if (!jn && !gfc_option.flag_range_check && mpfr_inf_p (last2))
+      if (!jn && !flag_range_check && mpfr_inf_p (last2))
 	{
 	  mpfr_set_inf (e->value.real, -1);
 	  gfc_constructor_append_expr (&result->value.constructor, e,
@@ -3324,7 +3324,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper,
   /* The last dimension of an assumed-size array is special.  */
   if ((!coarray && d == as->rank && as->type == AS_ASSUMED_SIZE && !upper)
       || (coarray && d == as->rank + as->corank
-	  && (!upper || gfc_option.coarray == GFC_FCOARRAY_SINGLE)))
+	  && (!upper || flag_coarray == GFC_FCOARRAY_SINGLE)))
     {
       if (as->lower[d-1]->expr_type == EXPR_CONSTANT)
 	{
@@ -4475,7 +4475,7 @@ gfc_simplify_nearest (gfc_expr *x, gfc_expr *s)
 
   /* Only NaN can occur. Do not use range check as it gives an
      error for denormal numbers.  */
-  if (mpfr_nan_p (result->value.real) && gfc_option.flag_range_check)
+  if (mpfr_nan_p (result->value.real) && flag_range_check)
     {
       gfc_error ("Result of NEAREST is NaN at %L", &result->where);
       gfc_free_expr (result);
@@ -4633,13 +4633,13 @@ gfc_simplify_num_images (gfc_expr *distance ATTRIBUTE_UNUSED, gfc_expr *failed)
 {
   gfc_expr *result;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+  if (flag_coarray == GFC_FCOARRAY_NONE)
     {
       gfc_fatal_error ("Coarrays disabled at %C, use %<-fcoarray=%> to enable");
       return &gfc_bad_expr;
     }
 
-  if (gfc_option.coarray != GFC_FCOARRAY_SINGLE)
+  if (flag_coarray != GFC_FCOARRAY_SINGLE)
     return NULL;
 
   if (failed && failed->expr_type != EXPR_CONSTANT)
@@ -5920,7 +5920,7 @@ gfc_simplify_sign (gfc_expr *x, gfc_expr *y)
 	break;
 
       case BT_REAL:
-	if (gfc_option.flag_sign_zero)
+	if (flag_sign_zero)
 	  mpfr_copysign (result->value.real, x->value.real, y->value.real,
 			GFC_RND_MODE);
 	else
@@ -6090,7 +6090,7 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_exp
   else
     mpz_init_set_ui (size, 1);
 
-  if (mpz_get_si (size)*ncopies > gfc_option.flag_max_array_constructor)
+  if (mpz_get_si (size)*ncopies > flag_max_array_constructor)
     return NULL;
 
   if (source->expr_type == EXPR_CONSTANT)
@@ -6525,7 +6525,7 @@ gfc_simplify_image_index (gfc_expr *coarray, gfc_expr *sub)
 
   gcc_assert (sub_cons == NULL);
 
-  if (gfc_option.coarray != GFC_FCOARRAY_SINGLE && !first_image)
+  if (flag_coarray != GFC_FCOARRAY_SINGLE && !first_image)
     return NULL;
 
   result = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind,
@@ -6543,7 +6543,7 @@ gfc_expr *
 gfc_simplify_this_image (gfc_expr *coarray, gfc_expr *dim,
 			 gfc_expr *distance ATTRIBUTE_UNUSED)
 {
-  if (gfc_option.coarray != GFC_FCOARRAY_SINGLE)
+  if (flag_coarray != GFC_FCOARRAY_SINGLE)
     return NULL;
 
   /* If no coarray argument has been passed or when the first argument
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index aab144a..20655c8 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -220,7 +220,7 @@ gfc_get_default_type (const char *name, gfc_namespace *ns)
 
   letter = name[0];
 
-  if (gfc_option.flag_allow_leading_underscore && letter == '_')
+  if (flag_allow_leading_underscore && letter == '_')
     gfc_fatal_error ("Option %<-fallow-leading-underscore%> is for use only by "
 		     "gfortran developers, and should not be used for "
 		     "implicitly typed variables");
@@ -2372,7 +2372,7 @@ gfc_get_namespace (gfc_namespace *parent, int parent_types)
 	  continue;
 	}
 
-      if (gfc_option.flag_implicit_none != 0)
+      if (flag_implicit_none != 0)
 	{
 	  gfc_clear_ts (ts);
 	  continue;
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index f02ff32..22309a0 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -298,7 +298,7 @@ gfc_conv_descriptor_token (tree desc)
 
   type = TREE_TYPE (desc);
   gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
-  gcc_assert (gfc_option.coarray == GFC_FCOARRAY_LIB);
+  gcc_assert (flag_coarray == GFC_FCOARRAY_LIB);
   field = gfc_advance_chain (TYPE_FIELDS (type), CAF_TOKEN_FIELD);
 
   /* Should be a restricted pointer - except in the finalization wrapper.  */
@@ -5277,7 +5277,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
   pointer = gfc_conv_descriptor_data_get (se->expr);
   STRIP_NOPS (pointer);
 
-  if (coarray && gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (coarray && flag_coarray == GFC_FCOARRAY_LIB)
     token = gfc_build_addr_expr (NULL_TREE,
 				 gfc_conv_descriptor_token (se->expr));
 
@@ -5360,7 +5360,7 @@ gfc_array_deallocate (tree descriptor, tree pstat, tree errmsg, tree errlen,
      the allocation status may not be changed.  */
   tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node,
 			 var, build_int_cst (TREE_TYPE (var), 0));
-  if (pstat != NULL_TREE && coarray && gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (pstat != NULL_TREE && coarray && flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree cond;
       tree stat = build_fold_indirect_ref_loc (input_location, pstat);
@@ -5430,8 +5430,7 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
 			       "constructor at %L requires an increase of "
 			       "the allowed %d upper limit. See "
 			       "%<-fmax-array-constructor%> option",
-			       &expr->where,
-			       gfc_option.flag_max_array_constructor);
+			       &expr->where, flag_max_array_constructor);
 	      return NULL_TREE;
 	    }
           if (mpz_cmp_si (c->offset, 0) != 0)
@@ -7265,7 +7264,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77,
 		  gfc_add_modify (&se->pre, new_field, old_field);
 		}
 
-	      if (gfc_option.coarray == GFC_FCOARRAY_LIB
+	      if (flag_coarray == GFC_FCOARRAY_LIB
 		  && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (old_desc))
 		  && GFC_TYPE_ARRAY_AKIND (TREE_TYPE (old_desc))
 		     == GFC_ARRAY_ALLOCATABLE)
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index a7d89c2..28523f5 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -254,7 +254,7 @@ gfc_sym_mangled_common_id (gfc_common_head *com)
   if (strcmp (name, BLANK_COMMON_NAME) == 0)
     return get_identifier (name);
 
-  if (gfc_option.flag_underscoring)
+  if (flag_underscoring)
     {
       has_underscore = strchr (name, '_') != 0;
       if (gfc_option.flag_second_underscore && has_underscore)
@@ -1125,7 +1125,7 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list)
 		       "extension to COMMON '%s' at %L", sym->name,
 		       common->name, &common->where);
 
-	  if (gfc_option.flag_align_commons)
+	  if (flag_align_commons)
 	    offset = align_segment (&align);
 
 	  if (offset)
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 780d350..a92b253 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -393,7 +393,7 @@ gfc_sym_mangled_function_id (gfc_symbol * sym)
       if (sym->attr.proc == PROC_INTRINSIC)
 	return get_identifier (sym->name);
 
-      if (gfc_option.flag_underscoring)
+      if (flag_underscoring)
 	{
 	  has_underscore = strchr (sym->name, '_') != 0;
 	  if (gfc_option.flag_second_underscore && has_underscore)
@@ -626,7 +626,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   if (!sym->attr.use_assoc
 	&& (sym->attr.save != SAVE_NONE || sym->attr.data
 	    || (sym->value && sym->ns->proc_name->attr.is_main_program)
-	    || (gfc_option.coarray == GFC_FCOARRAY_LIB
+	    || (flag_coarray == GFC_FCOARRAY_LIB
 		&& sym->attr.codimension && !sym->attr.allocatable)))
     TREE_STATIC (decl) = 1;
 
@@ -814,7 +814,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
   nest = (procns->proc_name->backend_decl != current_function_decl)
 	 && !sym->attr.contained;
 
-  if (sym->attr.codimension && gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (sym->attr.codimension && flag_coarray == GFC_FCOARRAY_LIB
       && sym->as->type != AS_ASSUMED_SHAPE
       && GFC_TYPE_ARRAY_CAF_TOKEN (type) == NULL_TREE)
     {
@@ -1013,7 +1013,7 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
 
       /* Even when -frepack-arrays is used, symbols with TARGET attribute
 	 are not repacked.  */
-      if (!gfc_option.flag_repack_arrays || sym->attr.target)
+      if (!flag_repack_arrays || sym->attr.target)
 	{
 	  if (as->type == AS_ASSUMED_SIZE)
 	    packed = PACKED_FULL;
@@ -1548,7 +1548,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       && (sym->attr.save || sym->ns->proc_name->attr.is_main_program
 	  || gfc_option.flag_max_stack_var_size == 0
 	  || sym->attr.data || sym->ns->proc_name->attr.flavor == FL_MODULE)
-      && (gfc_option.coarray != GFC_FCOARRAY_LIB
+      && (flag_coarray != GFC_FCOARRAY_LIB
 	  || !sym->attr.codimension || sym->attr.allocatable))
     {
       /* Add static initializer. For procedures, it is only needed if
@@ -1838,7 +1838,7 @@ module_sym:
 	    }
 	}
 
-      if (gfc_option.flag_f2c
+      if (flag_f2c
 	  && ((e.ts.type == BT_REAL && e.ts.kind == gfc_default_real_kind)
 	      || e.ts.type == BT_COMPLEX))
 	{
@@ -1958,7 +1958,7 @@ build_function_decl (gfc_symbol * sym, bool global)
   if (sym->attr.access == ACCESS_UNKNOWN && sym->module
       && (sym->ns->default_access == ACCESS_PRIVATE
 	  || (sym->ns->default_access == ACCESS_UNKNOWN
-	      && gfc_option.flag_module_private)))
+	      && flag_module_private)))
     sym->attr.access = ACCESS_PRIVATE;
 
   if (!current_function_decl
@@ -2301,7 +2301,7 @@ create_function_arglist (gfc_symbol * sym)
 
       /* Coarrays which are descriptorless or assumed-shape pass with
 	 -fcoarray=lib the token and the offset as hidden arguments.  */
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB
+      if (flag_coarray == GFC_FCOARRAY_LIB
 	  && ((f->sym->ts.type != BT_CLASS && f->sym->attr.codimension
 	       && !f->sym->attr.allocatable)
 	      || (f->sym->ts.type == BT_CLASS
@@ -3158,32 +3158,28 @@ gfc_build_intrinsic_function_decls (void)
 
     gfor_fndecl_sgemm = gfc_build_library_function_decl
 			  (get_identifier
-			     (gfc_option.flag_underscoring ? "sgemm_"
-							   : "sgemm"),
+			     (flag_underscoring ? "sgemm_" : "sgemm"),
 			   void_type_node, 15, pchar_type_node,
 			   pchar_type_node, pint, pint, pint, ps, ps, pint,
 			   ps, pint, ps, ps, pint, integer_type_node,
 			   integer_type_node);
     gfor_fndecl_dgemm = gfc_build_library_function_decl
 			  (get_identifier
-			     (gfc_option.flag_underscoring ? "dgemm_"
-							   : "dgemm"),
+			     (flag_underscoring ? "dgemm_" : "dgemm"),
 			   void_type_node, 15, pchar_type_node,
 			   pchar_type_node, pint, pint, pint, pd, pd, pint,
 			   pd, pint, pd, pd, pint, integer_type_node,
 			   integer_type_node);
     gfor_fndecl_cgemm = gfc_build_library_function_decl
 			  (get_identifier
-			     (gfc_option.flag_underscoring ? "cgemm_"
-							   : "cgemm"),
+			     (flag_underscoring ? "cgemm_" : "cgemm"),
 			   void_type_node, 15, pchar_type_node,
 			   pchar_type_node, pint, pint, pint, pc, pc, pint,
 			   pc, pint, pc, pc, pint, integer_type_node,
 			   integer_type_node);
     gfor_fndecl_zgemm = gfc_build_library_function_decl
 			  (get_identifier
-			     (gfc_option.flag_underscoring ? "zgemm_"
-							   : "zgemm"),
+			     (flag_underscoring ? "zgemm_" : "zgemm"),
 			   void_type_node, 15, pchar_type_node,
 			   pchar_type_node, pint, pint, pint, pz, pz, pint,
 			   pz, pint, pz, pz, pint, integer_type_node,
@@ -3331,7 +3327,7 @@ gfc_build_builtin_function_decls (void)
   TREE_NOTHROW (gfor_fndecl_associated) = 1;
 
   /* Coarray library calls.  */
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree pint_type, pppchar_type;
 
@@ -3845,8 +3841,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
 	    gfc_trans_dummy_character (proc_sym, proc_sym->ts.u.cl, block);
 	}
       else
-	gcc_assert (gfc_option.flag_f2c
-		    && proc_sym->ts.type == BT_COMPLEX);
+	gcc_assert (flag_f2c && proc_sym->ts.type == BT_COMPLEX);
     }
 
   /* Initialize the INTENT(OUT) derived type dummy arguments.  This
@@ -3895,7 +3890,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
 
 	  if (CLASS_DATA (sym)->attr.dimension
 	      || (CLASS_DATA (sym)->attr.codimension
-		  && gfc_option.coarray != GFC_FCOARRAY_LIB))
+		  && flag_coarray != GFC_FCOARRAY_LIB))
 	    {
 	      tmp = gfc_class_data_get (sym->backend_decl);
 	      tmp = gfc_build_null_descriptor (TREE_TYPE (tmp));
@@ -4426,7 +4421,7 @@ gfc_create_module_variable (gfc_symbol * sym)
       && (sym->attr.access == ACCESS_UNKNOWN
 	  && (sym->ns->default_access == ACCESS_PRIVATE
 	      || (sym->ns->default_access == ACCESS_UNKNOWN
-		  && gfc_option.flag_module_private))))
+		  && flag_module_private))))
     sym->attr.access = ACCESS_PRIVATE;
 
   if (warn_unused_variable && !sym->attr.referenced
@@ -4688,7 +4683,7 @@ gfc_emit_parameter_debug_info (gfc_symbol *sym)
 				   sym->attr.dimension, false))
     return;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)
+  if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)
     return;
 
   /* Create the decl for the variable or constant.  */
@@ -4878,7 +4873,7 @@ gfc_generate_module_vars (gfc_namespace * ns)
   gfc_traverse_ns (ns, gfc_create_module_variable);
   gfc_traverse_ns (ns, create_module_nml_decl);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
+  if (flag_coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
     generate_coarray_init (ns);
 
   cur_module = NULL;
@@ -5377,7 +5372,7 @@ create_main_function (tree fndecl)
   /* Call some libgfortran initialization routines, call then MAIN__().  */
 
   /* Call _gfortran_caf_init (*argc, ***argv).  */
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree pint_type, pppchar_type;
       pint_type = build_pointer_type (integer_type_node);
@@ -5425,11 +5420,9 @@ create_main_function (tree fndecl)
                             build_int_cst (integer_type_node,
                                            0));
     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
-                            build_int_cst (integer_type_node,
-                                           gfc_option.flag_backtrace));
+                            build_int_cst (integer_type_node, flag_backtrace));
     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
-                            build_int_cst (integer_type_node,
-                                           gfc_option.flag_sign_zero));
+                            build_int_cst (integer_type_node, flag_sign_zero));
     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
                             build_int_cst (integer_type_node,
                                            (gfc_option.rtcheck
@@ -5483,12 +5476,11 @@ create_main_function (tree fndecl)
   /* If this is the main program and an -fconvert option was provided,
      add a call to set_convert.  */
 
-  if (gfc_option.convert != GFC_CONVERT_NATIVE)
+  if (flag_convert != GFC_FLAG_CONVERT_NATIVE)
     {
       tmp = build_call_expr_loc (input_location,
 			     gfor_fndecl_set_convert, 1,
-			     build_int_cst (integer_type_node,
-					    gfc_option.convert));
+			     build_int_cst (integer_type_node, flag_convert));
       gfc_add_expr_to_block (&body, tmp);
     }
 
@@ -5522,7 +5514,7 @@ create_main_function (tree fndecl)
   TREE_USED (fndecl) = 1;
 
   /* Coarray: Call _gfortran_caf_finalize(void).  */
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       /* Per F2008, 8.5.1 END of the main program implies a
 	 SYNC MEMORY.  */
@@ -5712,7 +5704,7 @@ gfc_generate_function_code (gfc_namespace * ns)
   has_coarray_vars = false;
   generate_local_vars (ns);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
+  if (flag_coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
     generate_coarray_init (ns);
 
   /* Keep the parent fake result declaration in module functions
@@ -5727,8 +5719,7 @@ gfc_generate_function_code (gfc_namespace * ns)
 		 || (sym->attr.entry_master
 		     && sym->ns->entries->sym->attr.recursive);
   if ((gfc_option.rtcheck & GFC_RTCHECK_RECURSION)
-	&& !is_recursive
-	&& !gfc_option.flag_recursive)
+      && !is_recursive && !flag_recursive)
     {
       char * msg;
 
@@ -5826,9 +5817,7 @@ gfc_generate_function_code (gfc_namespace * ns)
 
   /* Reset recursion-check variable.  */
   if ((gfc_option.rtcheck & GFC_RTCHECK_RECURSION)
-	 && !is_recursive
-	 && !gfc_option.gfc_flag_openmp
-	 && recurcheckvar != NULL_TREE)
+      && !is_recursive && !flag_openmp && recurcheckvar != NULL_TREE)
     {
       gfc_add_modify (&cleanup, recurcheckvar, boolean_false_node);
       recurcheckvar = NULL;
@@ -5905,7 +5894,7 @@ gfc_generate_function_code (gfc_namespace * ns)
 	 If there are static coarrays in this function, the nested _caf_init
 	 function has already called cgraph_create_node, which also created
 	 the cgraph node for this function.  */
-      if (!has_coarray_vars || gfc_option.coarray != GFC_FCOARRAY_LIB)
+      if (!has_coarray_vars || flag_coarray != GFC_FCOARRAY_LIB)
 	(void) cgraph_node::create (fndecl);
     }
   else
@@ -6036,7 +6025,7 @@ gfc_process_block_locals (gfc_namespace* ns)
 
   generate_local_vars (ns);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
+  if (flag_coarray == GFC_FCOARRAY_LIB && has_coarray_vars)
     generate_coarray_init (ns);
 
   decl = saved_local_decls;
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index a82203c..44a2b07 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2056,7 +2056,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr)
 						se->expr);
 
           /* Dereference scalar hidden result.  */
-	  if (gfc_option.flag_f2c && sym->ts.type == BT_COMPLEX
+	  if (flag_f2c && sym->ts.type == BT_COMPLEX
 	      && (sym->attr.function || sym->attr.result)
 	      && !sym->attr.dimension && !sym->attr.pointer
 	      && !sym->attr.always_explicit)
@@ -5000,7 +5000,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
       /* For descriptorless coarrays and assumed-shape coarray dummies, we
 	 pass the token and the offset as additional arguments.  */
-      if (fsym && e == NULL && gfc_option.coarray == GFC_FCOARRAY_LIB
+      if (fsym && e == NULL && flag_coarray == GFC_FCOARRAY_LIB
 	  && ((fsym->ts.type != BT_CLASS && fsym->attr.codimension
 	       && !fsym->attr.allocatable)
 	      || (fsym->ts.type == BT_CLASS
@@ -5012,7 +5012,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	  vec_safe_push (stringargs, build_int_cst (gfc_array_index_type, 0));
 	  gcc_assert (fsym->attr.optional);
 	}
-      else if (fsym && gfc_option.coarray == GFC_FCOARRAY_LIB
+      else if (fsym && flag_coarray == GFC_FCOARRAY_LIB
 	       && ((fsym->ts.type != BT_CLASS && fsym->attr.codimension
 		    && !fsym->attr.allocatable)
 		   || (fsym->ts.type == BT_CLASS
@@ -5304,7 +5304,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	}
       else
 	{
-	  gcc_assert (gfc_option.flag_f2c && ts.type == BT_COMPLEX);
+	  gcc_assert (flag_f2c && ts.type == BT_COMPLEX);
 
 	  type = gfc_get_complex_type (ts.kind);
 	  var = gfc_build_addr_expr (NULL_TREE, gfc_create_var (type, "cmplx"));
@@ -5385,7 +5385,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
      return a double precision result.  Convert this back to default
      real.  We only care about the cases that can happen in Fortran 77.
   */
-  if (gfc_option.flag_f2c && sym->ts.type == BT_REAL
+  if (flag_f2c && sym->ts.type == BT_REAL
       && sym->ts.kind == gfc_default_real_kind
       && !sym->attr.always_explicit)
     se->expr = fold_convert (gfc_get_real_type (sym->ts.kind), se->expr);
@@ -5436,7 +5436,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	    }
 	  else
 	    {
-	      gcc_assert (ts.type == BT_COMPLEX && gfc_option.flag_f2c);
+	      gcc_assert (ts.type == BT_COMPLEX && flag_f2c);
 	      se->expr = build_fold_indirect_ref_loc (input_location, var);
 	    }
 	}
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 4ebe492..888f927 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -1106,7 +1106,7 @@ gfc_conv_intrinsic_caf_get (gfc_se *se, gfc_expr *expr, tree lhs, tree lhs_kind,
   tree caf_decl, token, offset, image_index, tmp;
   tree res_var, dst_var, type, kind, vec;
 
-  gcc_assert (gfc_option.coarray == GFC_FCOARRAY_LIB);
+  gcc_assert (flag_coarray == GFC_FCOARRAY_LIB);
 
   if (se->ss && se->ss->info->useflags)
     {
@@ -1236,7 +1236,7 @@ conv_caf_send (gfc_code *code) {
   tree lhs_type = NULL_TREE;
   tree vec = null_pointer_node, rhs_vec = null_pointer_node;
 
-  gcc_assert (gfc_option.coarray == GFC_FCOARRAY_LIB);
+  gcc_assert (flag_coarray == GFC_FCOARRAY_LIB);
 
   lhs_expr = code->ext.actual->expr;
   rhs_expr = code->ext.actual->next->expr;
@@ -1404,7 +1404,7 @@ trans_this_image (gfc_se * se, gfc_expr *expr)
     distance = expr->value.function.actual->expr;
 
   /* The case -fcoarray=single is handled elsewhere.  */
-  gcc_assert (gfc_option.coarray != GFC_FCOARRAY_SINGLE);
+  gcc_assert (flag_coarray != GFC_FCOARRAY_SINGLE);
 
   /* Argument-free version: THIS_IMAGE().  */
   if (distance || expr->value.function.actual->expr == NULL)
@@ -1716,7 +1716,7 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
 
   /* Return 0 if "coindex" exceeds num_images().  */
 
-  if (gfc_option.coarray == GFC_FCOARRAY_SINGLE)
+  if (flag_coarray == GFC_FCOARRAY_SINGLE)
     num_images = build_int_cst (type, 1);
   else
     {
@@ -2098,7 +2098,7 @@ conv_intrinsic_cobound (gfc_se * se, gfc_expr * expr)
          where size is the product of the extent of all but the last
 	 codimension.  */
 
-      if (gfc_option.coarray != GFC_FCOARRAY_SINGLE && corank > 1)
+      if (flag_coarray != GFC_FCOARRAY_SINGLE && corank > 1)
 	{
           tree cosize;
 
@@ -2116,7 +2116,7 @@ conv_intrinsic_cobound (gfc_se * se, gfc_expr * expr)
 	  resbound = fold_build2_loc (input_location, PLUS_EXPR,
 				      gfc_array_index_type, resbound, tmp);
 	}
-      else if (gfc_option.coarray != GFC_FCOARRAY_SINGLE)
+      else if (flag_coarray != GFC_FCOARRAY_SINGLE)
 	{
 	  /* ubound = lbound + num_images() - 1.  */
 	  tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_num_images,
@@ -2470,7 +2470,7 @@ gfc_conv_intrinsic_sign (gfc_se * se, gfc_expr * expr)
 
       /* We explicitly have to ignore the minus sign. We do so by using
 	 result = (arg1 == 0) ? abs(arg0) : copysign(arg0, arg1).  */
-      if (!gfc_option.flag_sign_zero
+      if (!flag_sign_zero
 	  && MODE_HAS_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (args[1]))))
 	{
 	  tree cond, zero;
@@ -2978,7 +2978,7 @@ gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr * expr)
     {
       tree cint = gfc_get_int_type (gfc_c_int_kind);
 
-      if (gfc_option.flag_external_blas
+      if (flag_external_blas
 	  && (sym->ts.type == BT_REAL || sym->ts.type == BT_COMPLEX)
 	  && (sym->ts.kind == 4 || sym->ts.kind == 8))
 	{
@@ -3002,7 +3002,7 @@ gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr * expr)
 	  vec_alloc (append_args, 3);
 	  append_args->quick_push (build_int_cst (cint, 1));
 	  append_args->quick_push (build_int_cst (cint,
-		                                 gfc_option.blas_matmul_limit));
+						  flag_blas_matmul_limit));
 	  append_args->quick_push (gfc_build_addr_expr (NULL_TREE,
 							gemm_fndecl));
 	}
@@ -8137,7 +8137,7 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
     case GFC_ISYM_THIS_IMAGE:
       /* For num_images() == 1, handle as LCOBOUND.  */
       if (expr->value.function.actual->expr
-	  && gfc_option.coarray == GFC_FCOARRAY_SINGLE)
+	  && flag_coarray == GFC_FCOARRAY_SINGLE)
 	conv_intrinsic_cobound (se, expr);
       else
 	trans_this_image (se, expr);
@@ -8592,16 +8592,16 @@ conv_co_collective (gfc_code *code)
       gfc_add_block_to_block (&block, &argse.pre);
       gfc_add_block_to_block (&post_block, &argse.post);
       stat = argse.expr;
-      if (gfc_option.coarray != GFC_FCOARRAY_SINGLE)
+      if (flag_coarray != GFC_FCOARRAY_SINGLE)
 	stat = gfc_build_addr_expr (NULL_TREE, stat);
     }
-  else if (gfc_option.coarray == GFC_FCOARRAY_SINGLE)
+  else if (flag_coarray == GFC_FCOARRAY_SINGLE)
     stat = NULL_TREE;
   else
     stat = null_pointer_node;
 
   /* Early exit for GFC_FCOARRAY_SINGLE.  */
-  if (gfc_option.coarray == GFC_FCOARRAY_SINGLE)
+  if (flag_coarray == GFC_FCOARRAY_SINGLE)
     {
       if (stat != NULL_TREE)
 	gfc_add_modify (&block, stat,
@@ -8761,7 +8761,7 @@ conv_intrinsic_atomic_op (gfc_code *code)
   atom = argse.expr;
 
   gfc_init_se (&argse, NULL);
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (flag_coarray == GFC_FCOARRAY_LIB
       && code->ext.actual->next->expr->ts.kind == atom_expr->ts.kind)
     argse.want_pointer = 1;
   gfc_conv_expr (&argse, code->ext.actual->next->expr);
@@ -8777,12 +8777,12 @@ conv_intrinsic_atomic_op (gfc_code *code)
     case GFC_ISYM_ATOMIC_OR:
     case GFC_ISYM_ATOMIC_XOR:
       stat_expr = code->ext.actual->next->next->expr;
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (flag_coarray == GFC_FCOARRAY_LIB)
 	old = null_pointer_node;
       break;
     default:
       gfc_init_se (&argse, NULL);
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (flag_coarray == GFC_FCOARRAY_LIB)
 	argse.want_pointer = 1;
       gfc_conv_expr (&argse, code->ext.actual->next->next->expr);
       gfc_add_block_to_block (&block, &argse.pre);
@@ -8796,17 +8796,17 @@ conv_intrinsic_atomic_op (gfc_code *code)
     {
       gcc_assert (stat_expr->expr_type == EXPR_VARIABLE);
       gfc_init_se (&argse, NULL);
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (flag_coarray == GFC_FCOARRAY_LIB)
 	argse.want_pointer = 1;
       gfc_conv_expr_val (&argse, stat_expr);
       gfc_add_block_to_block (&block, &argse.pre);
       gfc_add_block_to_block (&post_block, &argse.post);
       stat = argse.expr;
     }
-  else if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  else if (flag_coarray == GFC_FCOARRAY_LIB)
     stat = null_pointer_node;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree image_index, caf_decl, offset, token;
       int op;
@@ -8960,7 +8960,7 @@ conv_intrinsic_atomic_ref (gfc_code *code)
   atom = argse.expr;
 
   gfc_init_se (&argse, NULL);
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (flag_coarray == GFC_FCOARRAY_LIB
       && code->ext.actual->expr->ts.kind == atom_expr->ts.kind)
     argse.want_pointer = 1;
   gfc_conv_expr (&argse, code->ext.actual->expr);
@@ -8974,17 +8974,17 @@ conv_intrinsic_atomic_ref (gfc_code *code)
       gcc_assert (code->ext.actual->next->next->expr->expr_type
 		  == EXPR_VARIABLE);
       gfc_init_se (&argse, NULL);
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (flag_coarray == GFC_FCOARRAY_LIB)
 	argse.want_pointer = 1;
       gfc_conv_expr_val (&argse, code->ext.actual->next->next->expr);
       gfc_add_block_to_block (&block, &argse.pre);
       gfc_add_block_to_block (&post_block, &argse.post);
       stat = argse.expr;
     }
-  else if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  else if (flag_coarray == GFC_FCOARRAY_LIB)
     stat = null_pointer_node;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree image_index, caf_decl, offset, token;
       tree orig_value = NULL_TREE, vardecl = NULL_TREE;
@@ -9061,7 +9061,7 @@ conv_intrinsic_atomic_cas (gfc_code *code)
   atom = argse.expr;
 
   gfc_init_se (&argse, NULL);
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     argse.want_pointer = 1;
   gfc_conv_expr (&argse, code->ext.actual->next->expr);
   gfc_add_block_to_block (&block, &argse.pre);
@@ -9069,7 +9069,7 @@ conv_intrinsic_atomic_cas (gfc_code *code)
   old = argse.expr;
 
   gfc_init_se (&argse, NULL);
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     argse.want_pointer = 1;
   gfc_conv_expr (&argse, code->ext.actual->next->next->expr);
   gfc_add_block_to_block (&block, &argse.pre);
@@ -9077,7 +9077,7 @@ conv_intrinsic_atomic_cas (gfc_code *code)
   comp = argse.expr;
 
   gfc_init_se (&argse, NULL);
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (flag_coarray == GFC_FCOARRAY_LIB
       && code->ext.actual->next->next->next->expr->ts.kind
 	 == atom_expr->ts.kind)
     argse.want_pointer = 1;
@@ -9092,7 +9092,7 @@ conv_intrinsic_atomic_cas (gfc_code *code)
       gcc_assert (code->ext.actual->next->next->next->next->expr->expr_type
 		  == EXPR_VARIABLE);
       gfc_init_se (&argse, NULL);
-      if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (flag_coarray == GFC_FCOARRAY_LIB)
 	argse.want_pointer = 1;
       gfc_conv_expr_val (&argse,
 			 code->ext.actual->next->next->next->next->expr);
@@ -9100,10 +9100,10 @@ conv_intrinsic_atomic_cas (gfc_code *code)
       gfc_add_block_to_block (&post_block, &argse.post);
       stat = argse.expr;
     }
-  else if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  else if (flag_coarray == GFC_FCOARRAY_LIB)
     stat = null_pointer_node;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree image_index, caf_decl, offset, token;
 
@@ -9357,7 +9357,7 @@ conv_intrinsic_move_alloc (gfc_code *code)
 
   /* For coarrays, call SYNC ALL if TO is already deallocated as MOVE_ALLOC
      is an image control "statement", cf. IR F08/0040 in 12-006A.  */
-  if (coarray && gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (coarray && flag_coarray == GFC_FCOARRAY_LIB)
     {
       tree cond;
 
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index c7edcad..707a089 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -3435,7 +3435,7 @@ gfc_trans_omp_do_simd (gfc_code *code, stmtblock_t *pblock,
       clausesa = clausesa_buf;
       gfc_split_omp_clauses (code, clausesa);
     }
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     omp_do_clauses
       = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_DO], code->loc);
   body = gfc_trans_omp_do (code, EXEC_OMP_SIMD, pblock ? pblock : &block,
@@ -3449,7 +3449,7 @@ gfc_trans_omp_do_simd (gfc_code *code, stmtblock_t *pblock,
     }
   else if (TREE_CODE (body) != BIND_EXPR)
     body = build3_v (BIND_EXPR, NULL, body, NULL_TREE);
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     {
       stmt = make_node (OMP_FOR);
       TREE_TYPE (stmt) = void_type_node;
@@ -3527,7 +3527,7 @@ gfc_trans_omp_parallel_do_simd (gfc_code *code, stmtblock_t *pblock,
       clausesa = clausesa_buf;
       gfc_split_omp_clauses (code, clausesa);
     }
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     omp_clauses
       = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_PARALLEL],
 			       code->loc);
@@ -3543,7 +3543,7 @@ gfc_trans_omp_parallel_do_simd (gfc_code *code, stmtblock_t *pblock,
     }
   else if (TREE_CODE (stmt) != BIND_EXPR)
     stmt = build3_v (BIND_EXPR, NULL, stmt, NULL_TREE);
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     {
       stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
 			 omp_clauses);
@@ -3698,7 +3698,7 @@ gfc_trans_omp_distribute (gfc_code *code, gfc_omp_clauses *clausesa)
       clausesa = clausesa_buf;
       gfc_split_omp_clauses (code, clausesa);
     }
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     omp_clauses
       = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_DISTRIBUTE],
 			       code->loc);
@@ -3741,7 +3741,7 @@ gfc_trans_omp_distribute (gfc_code *code, gfc_omp_clauses *clausesa)
     default:
       gcc_unreachable ();
     }
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     {
       tree distribute = make_node (OMP_DISTRIBUTE);
       TREE_TYPE (distribute) = void_type_node;
@@ -3766,7 +3766,7 @@ gfc_trans_omp_teams (gfc_code *code, gfc_omp_clauses *clausesa)
       clausesa = clausesa_buf;
       gfc_split_omp_clauses (code, clausesa);
     }
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     omp_clauses
       = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_TEAMS],
 			       code->loc);
@@ -3801,7 +3801,7 @@ gfc_trans_omp_target (gfc_code *code)
 
   gfc_start_block (&block);
   gfc_split_omp_clauses (code, clausesa);
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     omp_clauses
       = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_TARGET],
 			       code->loc);
@@ -3811,7 +3811,7 @@ gfc_trans_omp_target (gfc_code *code)
     stmt = gfc_trans_omp_teams (code, clausesa);
   if (TREE_CODE (stmt) != BIND_EXPR)
     stmt = build3_v (BIND_EXPR, NULL, stmt, NULL_TREE);
-  if (gfc_option.gfc_flag_openmp)
+  if (flag_openmp)
     stmt = build2_loc (input_location, OMP_TARGET, void_type_node, stmt,
 		       omp_clauses);
   gfc_add_expr_to_block (&block, stmt);
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 1ba382a..985fc0b 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -627,7 +627,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
   gfc_init_se (&se, NULL);
   gfc_start_block (&se.pre);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && !error_stop)
+  if (flag_coarray == GFC_FCOARRAY_LIB && !error_stop)
     {
       /* Per F2008, 8.5.1 STOP implies a SYNC MEMORY.  */
       tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE);
@@ -643,7 +643,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
       tmp = build_int_cst (gfc_int4_type_node, 0);
       tmp = build_call_expr_loc (input_location,
 				 error_stop
-				 ? (gfc_option.coarray == GFC_FCOARRAY_LIB
+				 ? (flag_coarray == GFC_FCOARRAY_LIB
 				    ? gfor_fndecl_caf_error_stop_str
 				    : gfor_fndecl_error_stop_string)
 				 : gfor_fndecl_stop_string,
@@ -654,7 +654,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
       gfc_conv_expr (&se, code->expr1);
       tmp = build_call_expr_loc (input_location,
 				 error_stop
-				 ? (gfc_option.coarray == GFC_FCOARRAY_LIB
+				 ? (flag_coarray == GFC_FCOARRAY_LIB
 				    ? gfor_fndecl_caf_error_stop
 				    : gfor_fndecl_error_stop_numeric)
 				 : gfor_fndecl_stop_numeric_f08, 1,
@@ -665,7 +665,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
       gfc_conv_expr_reference (&se, code->expr1);
       tmp = build_call_expr_loc (input_location,
 				 error_stop
-				 ? (gfc_option.coarray == GFC_FCOARRAY_LIB
+				 ? (flag_coarray == GFC_FCOARRAY_LIB
 				    ? gfor_fndecl_caf_error_stop_str
 				    : gfor_fndecl_error_stop_string)
 				 : gfor_fndecl_stop_string,
@@ -688,7 +688,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op type ATTRIBUTE_UNUSED)
 
   /* Short cut: For single images without STAT= or LOCK_ACQUIRED
      return early. (ERRMSG= is always untouched for -fcoarray=single.)  */
-  if (!code->expr2 && !code->expr4 && gfc_option.coarray != GFC_FCOARRAY_LIB)
+  if (!code->expr2 && !code->expr4 && flag_coarray != GFC_FCOARRAY_LIB)
     return NULL_TREE;
 
   gfc_init_se (&se, NULL);
@@ -733,7 +733,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
   /* Short cut: For single images without bound checking or without STAT=,
      return early. (ERRMSG= is always untouched for -fcoarray=single.)  */
   if (!code->expr2 && !(gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
-      && gfc_option.coarray != GFC_FCOARRAY_LIB)
+      && flag_coarray != GFC_FCOARRAY_LIB)
     return NULL_TREE;
 
   gfc_init_se (&se, NULL);
@@ -756,7 +756,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
   else
     stat = null_pointer_node;
 
-  if (code->expr3 && gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (code->expr3 && flag_coarray == GFC_FCOARRAY_LIB
       && type != EXEC_SYNC_MEMORY)
     {
       gcc_assert (code->expr3->expr_type == EXPR_VARIABLE);
@@ -766,7 +766,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
       errmsg = gfc_build_addr_expr (NULL, argse.expr);
       errmsglen = argse.string_length;
     }
-  else if (gfc_option.coarray == GFC_FCOARRAY_LIB && type != EXEC_SYNC_MEMORY)
+  else if (flag_coarray == GFC_FCOARRAY_LIB && type != EXEC_SYNC_MEMORY)
     {
       errmsg = null_pointer_node;
       errmsglen = build_int_cst (integer_type_node, 0);
@@ -778,7 +778,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
       && code->expr1->rank == 0)
     {
       tree cond;
-      if (gfc_option.coarray != GFC_FCOARRAY_LIB)
+      if (flag_coarray != GFC_FCOARRAY_LIB)
 	cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
 				images, build_int_cst (TREE_TYPE (images), 1));
       else
@@ -803,14 +803,14 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
 
    /* Per F2008, 8.5.1, a SYNC MEMORY is implied by calling the
       image control statements SYNC IMAGES and SYNC ALL.  */
-   if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+   if (flag_coarray == GFC_FCOARRAY_LIB)
      {
        tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE);
        tmp = build_call_expr_loc (input_location, tmp, 0);
        gfc_add_expr_to_block (&se.pre, tmp);
      }
 
-  if (gfc_option.coarray != GFC_FCOARRAY_LIB || type == EXEC_SYNC_MEMORY)
+  if (flag_coarray != GFC_FCOARRAY_LIB || type == EXEC_SYNC_MEMORY)
     {
       /* Set STAT to zero.  */
       if (code->expr2)
@@ -1115,7 +1115,7 @@ gfc_trans_critical (gfc_code *code)
 
   gfc_start_block (&block);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       token = gfc_get_symbol_decl (code->resolved_sym);
       token = GFC_TYPE_ARRAY_CAF_TOKEN (TREE_TYPE (token));
@@ -1129,7 +1129,7 @@ gfc_trans_critical (gfc_code *code)
   tmp = gfc_trans_code (code->block->next);
   gfc_add_expr_to_block (&block, tmp);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB)
+  if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_unlock, 6,
 				 token, integer_zero_node, integer_one_node,
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 12536e9..b14edb1 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -1648,7 +1648,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
 
   if (as->rank == 0)
     {
-      if (packed != PACKED_STATIC  || gfc_option.coarray == GFC_FCOARRAY_LIB)
+      if (packed != PACKED_STATIC  || flag_coarray == GFC_FCOARRAY_LIB)
 	{
 	  type = build_pointer_type (type);
 
@@ -1702,7 +1702,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
     }
 
   if (packed != PACKED_STATIC || !known_stride
-      || (as->corank && gfc_option.coarray == GFC_FCOARRAY_LIB))
+      || (as->corank && flag_coarray == GFC_FCOARRAY_LIB))
     {
       /* For dummy arrays and automatic (heap allocated) arrays we
 	 want a pointer to the array.  */
@@ -1734,7 +1734,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted,
 
   gcc_assert (codimen + dimen >= 0 && codimen + dimen <= GFC_MAX_DIMENSIONS);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && codimen)
+  if (flag_coarray == GFC_FCOARRAY_LIB && codimen)
     {
       if (gfc_array_descriptor_base_caf[idx])
 	return gfc_array_descriptor_base_caf[idx];
@@ -1782,7 +1782,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted,
       TREE_NO_WARNING (decl) = 1;
     }
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && codimen
+  if (flag_coarray == GFC_FCOARRAY_LIB && codimen
       && akind == GFC_ARRAY_ALLOCATABLE)
     {
       decl = gfc_add_field_to_struct_1 (fat_type,
@@ -1795,7 +1795,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted,
   gfc_finish_type (fat_type);
   TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (fat_type)) = 1;
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB && codimen
+  if (flag_coarray == GFC_FCOARRAY_LIB && codimen
       && akind == GFC_ARRAY_ALLOCATABLE)
     gfc_array_descriptor_base_caf[idx] = fat_type;
   else
@@ -2447,7 +2447,7 @@ gfc_get_derived_type (gfc_symbol * derived)
       /* We see this derived type first time, so build the type node.  */
       typenode = make_node (RECORD_TYPE);
       TYPE_NAME (typenode) = get_identifier (derived->name);
-      TYPE_PACKED (typenode) = gfc_option.flag_pack_derived;
+      TYPE_PACKED (typenode) = flag_pack_derived;
       derived->backend_decl = typenode;
     }
 
@@ -2630,8 +2630,7 @@ gfc_return_by_reference (gfc_symbol * sym)
      -fno-f2c calling convention), nor for calls to functions which always
      require an explicit interface, as no compatibility problems can
      arise there.  */
-  if (gfc_option.flag_f2c
-      && sym->ts.type == BT_COMPLEX
+  if (flag_f2c && sym->ts.type == BT_COMPLEX
       && !sym->attr.intrinsic && !sym->attr.always_explicit)
     return 1;
 
@@ -2865,8 +2864,7 @@ arg_type_list_done:
     type = void_type_node;
   else if (sym->attr.mixed_entry_master)
     type = gfc_get_mixed_entry_union (sym->ns);
-  else if (gfc_option.flag_f2c
-	   && sym->ts.type == BT_REAL
+  else if (flag_f2c && sym->ts.type == BT_REAL
 	   && sym->ts.kind == gfc_default_real_kind
 	   && !sym->attr.always_explicit)
     {
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 76fe7fd..7c54b8e 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -772,7 +772,7 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token,
      gfc_allocate_using_lib.  */
   gfc_start_block (&alloc_block);
 
-  if (gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (flag_coarray == GFC_FCOARRAY_LIB
       && gfc_expr_attr (expr).codimension)
     {
       tree cond;
@@ -1263,7 +1263,7 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg,
   /* When POINTER is not NULL, we free it.  */
   gfc_start_block (&non_null);
   gfc_add_finalizer_call (&non_null, expr);
-  if (!coarray || gfc_option.coarray != GFC_FCOARRAY_LIB)
+  if (!coarray || flag_coarray != GFC_FCOARRAY_LIB)
     {
       tmp = build_call_expr_loc (input_location,
 				 builtin_decl_explicit (BUILT_IN_FREE), 1,
