OSDN Git Service

* langhooks-def.h (lhd_init_options, LANG_HOOKS_OPTION_LANG_MASK,
[pf3gnuchains/gcc-fork.git] / gcc / fortran / options.c
1 /* Parse and display command line options.
2    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3    2009, 2010
4    Free Software Foundation, Inc.
5    Contributed by Andy Vaught
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tree.h"
27 #include "flags.h"
28 #include "intl.h"
29 #include "opts.h"
30 #include "options.h"
31 #include "params.h"
32 #include "tree-inline.h"
33 #include "gfortran.h"
34 #include "target.h"
35 #include "cpp.h"
36 #include "diagnostic-core.h"    /* For sorry.  */
37 #include "tm.h"
38
39 gfc_option_t gfc_option;
40
41
42 /* Set flags that control warnings and errors for different
43    Fortran standards to their default values.  Keep in sync with
44    libgfortran/runtime/compile_options.c (init_compile_options).  */
45
46 static void
47 set_default_std_flags (void)
48 {
49   gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
50     | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
51     | GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY;
52   gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
53 }
54
55
56 /* Return language mask for Fortran options.  */
57
58 unsigned int
59 gfc_option_lang_mask (void)
60 {
61   return CL_Fortran;
62 }
63
64
65 /* Get ready for options handling. Keep in sync with
66    libgfortran/runtime/compile_options.c (init_compile_options). */
67
68 void
69 gfc_init_options (unsigned int decoded_options_count,
70                   struct cl_decoded_option *decoded_options)
71 {
72   gfc_source_file = NULL;
73   gfc_option.module_dir = NULL;
74   gfc_option.source_form = FORM_UNKNOWN;
75   gfc_option.fixed_line_length = 72;
76   gfc_option.free_line_length = 132;
77   gfc_option.max_continue_fixed = 255;
78   gfc_option.max_continue_free = 255;
79   gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
80   gfc_option.max_subrecord_length = 0;
81   gfc_option.flag_max_array_constructor = 65535;
82   gfc_option.convert = GFC_CONVERT_NATIVE;
83   gfc_option.record_marker = 0;
84   gfc_option.dump_parse_tree = 0;
85
86   gfc_option.warn_aliasing = 0;
87   gfc_option.warn_ampersand = 0;
88   gfc_option.warn_character_truncation = 0;
89   gfc_option.warn_array_temp = 0;
90   gfc_option.warn_conversion = 0;
91   gfc_option.warn_conversion_extra = 0;
92   gfc_option.warn_implicit_interface = 0;
93   gfc_option.warn_line_truncation = 0;
94   gfc_option.warn_surprising = 0;
95   gfc_option.warn_tabs = 1;
96   gfc_option.warn_underflow = 1;
97   gfc_option.warn_intrinsic_shadow = 0;
98   gfc_option.warn_intrinsics_std = 0;
99   gfc_option.warn_align_commons = 1;
100   gfc_option.warn_unused_dummy_argument = 0;
101   gfc_option.max_errors = 25;
102
103   gfc_option.flag_all_intrinsics = 0;
104   gfc_option.flag_default_double = 0;
105   gfc_option.flag_default_integer = 0;
106   gfc_option.flag_default_real = 0;
107   gfc_option.flag_dollar_ok = 0;
108   gfc_option.flag_underscoring = 1;
109   gfc_option.flag_whole_file = 1;
110   gfc_option.flag_f2c = 0;
111   gfc_option.flag_second_underscore = -1;
112   gfc_option.flag_implicit_none = 0;
113
114   /* Default value of flag_max_stack_var_size is set in gfc_post_options.  */
115   gfc_option.flag_max_stack_var_size = -2;
116
117   gfc_option.flag_range_check = 1;
118   gfc_option.flag_pack_derived = 0;
119   gfc_option.flag_repack_arrays = 0;
120   gfc_option.flag_preprocessed = 0;
121   gfc_option.flag_automatic = 1;
122   gfc_option.flag_backslash = 0;
123   gfc_option.flag_module_private = 0;
124   gfc_option.flag_backtrace = 0;
125   gfc_option.flag_allow_leading_underscore = 0;
126   gfc_option.flag_dump_core = 0;
127   gfc_option.flag_external_blas = 0;
128   gfc_option.blas_matmul_limit = 30;
129   gfc_option.flag_cray_pointer = 0;
130   gfc_option.flag_d_lines = -1;
131   gfc_option.flag_openmp = 0;
132   gfc_option.flag_sign_zero = 1;
133   gfc_option.flag_recursive = 0;
134   gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
135   gfc_option.flag_init_integer_value = 0;
136   gfc_option.flag_init_real = GFC_INIT_REAL_OFF;
137   gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
138   gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
139   gfc_option.flag_init_character_value = (char)0;
140   gfc_option.flag_align_commons = 1;
141   gfc_option.flag_protect_parens = 1;
142   
143   gfc_option.fpe = 0;
144   gfc_option.rtcheck = 0;
145   gfc_option.coarray = GFC_FCOARRAY_NONE;
146
147   flag_errno_math = 0;
148   flag_associative_math = -1;
149
150   set_default_std_flags ();
151
152   /* -fshort-enums can be default on some targets.  */
153   flag_short_enums = targetm.default_short_enums ();
154
155   /* Initialize cpp-related options.  */
156   gfc_cpp_init_options (decoded_options_count, decoded_options);
157 }
158
159
160 /* Determine the source form from the filename extension.  We assume
161    case insensitivity.  */
162
163 static gfc_source_form
164 form_from_filename (const char *filename)
165 {
166   static const struct
167   {
168     const char *extension;
169     gfc_source_form form;
170   }
171   exttype[] =
172   {
173     {
174     ".f90", FORM_FREE}
175     ,
176     {
177     ".f95", FORM_FREE}
178     ,
179     {
180     ".f03", FORM_FREE}
181     ,
182     {
183     ".f08", FORM_FREE}
184     ,
185     {
186     ".f", FORM_FIXED}
187     ,
188     {
189     ".for", FORM_FIXED}
190     ,
191     {
192     ".ftn", FORM_FIXED}
193     ,
194     {
195     "", FORM_UNKNOWN}
196   };            /* sentinel value */
197
198   gfc_source_form f_form;
199   const char *fileext;
200   int i;
201
202   /* Find end of file name.  Note, filename is either a NULL pointer or
203      a NUL terminated string.  */
204   i = 0;
205   while (filename[i] != '\0')
206     i++;
207
208   /* Find last period.  */
209   while (i >= 0 && (filename[i] != '.'))
210     i--;
211
212   /* Did we see a file extension?  */
213   if (i < 0)
214     return FORM_UNKNOWN; /* Nope  */
215
216   /* Get file extension and compare it to others.  */
217   fileext = &(filename[i]);
218
219   i = -1;
220   f_form = FORM_UNKNOWN;
221   do
222     {
223       i++;
224       if (strcasecmp (fileext, exttype[i].extension) == 0)
225         {
226           f_form = exttype[i].form;
227           break;
228         }
229     }
230   while (exttype[i].form != FORM_UNKNOWN);
231
232   return f_form;
233 }
234
235
236 /* Finalize commandline options.  */
237
238 bool
239 gfc_post_options (const char **pfilename)
240 {
241   const char *filename = *pfilename, *canon_source_file = NULL;
242   char *source_path;
243   int i;
244
245   /* Excess precision other than "fast" requires front-end
246      support.  */
247   if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
248       && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
249     sorry ("-fexcess-precision=standard for Fortran");
250   flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
251
252   /* Whole program needs whole file mode.  */
253   if (flag_whole_program)
254     gfc_option.flag_whole_file = 1;
255
256   /* Enable whole-file mode if LTO is in effect.  */
257   if (flag_lto || flag_whopr)
258     gfc_option.flag_whole_file = 1;
259
260   /* Fortran allows associative math - but we cannot reassociate if
261      we want traps or signed zeros. Cf. also flag_protect_parens.  */
262   if (flag_associative_math == -1)
263     flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
264
265   /* -fbounds-check is equivalent to -fcheck=bounds */
266   if (flag_bounds_check)
267     gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
268
269   if (flag_compare_debug)
270     gfc_option.dump_parse_tree = 0;
271
272   /* Verify the input file name.  */
273   if (!filename || strcmp (filename, "-") == 0)
274     {
275       filename = "";
276     }
277
278   if (gfc_option.flag_preprocessed)
279     {
280       /* For preprocessed files, if the first tokens are of the form # NUM.
281          handle the directives so we know the original file name.  */
282       gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
283       if (gfc_source_file == NULL)
284         gfc_source_file = filename;
285       else
286         *pfilename = gfc_source_file;
287     }
288   else
289     gfc_source_file = filename;
290
291   if (canon_source_file == NULL)
292     canon_source_file = gfc_source_file;
293
294   /* Adds the path where the source file is to the list of include files.  */
295
296   i = strlen (canon_source_file);
297   while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
298     i--;
299
300   if (i != 0)
301     {
302       source_path = (char *) alloca (i + 1);
303       memcpy (source_path, canon_source_file, i);
304       source_path[i] = 0;
305       gfc_add_include_path (source_path, true, true);
306     }
307   else
308     gfc_add_include_path (".", true, true);
309
310   if (canon_source_file != gfc_source_file)
311     gfc_free (CONST_CAST (char *, canon_source_file));
312
313   /* Decide which form the file will be read in as.  */
314
315   if (gfc_option.source_form != FORM_UNKNOWN)
316     gfc_current_form = gfc_option.source_form;
317   else
318     {
319       gfc_current_form = form_from_filename (filename);
320
321       if (gfc_current_form == FORM_UNKNOWN)
322         {
323           gfc_current_form = FORM_FREE;
324           gfc_warning_now ("Reading file '%s' as free form", 
325                            (filename[0] == '\0') ? "<stdin>" : filename);
326         }
327     }
328
329   /* If the user specified -fd-lines-as-{code|comments} verify that we're
330      in fixed form.  */
331   if (gfc_current_form == FORM_FREE)
332     {
333       if (gfc_option.flag_d_lines == 0)
334         gfc_warning_now ("'-fd-lines-as-comments' has no effect "
335                          "in free form");
336       else if (gfc_option.flag_d_lines == 1)
337         gfc_warning_now ("'-fd-lines-as-code' has no effect in free form");
338     }
339
340   /* If -pedantic, warn about the use of GNU extensions.  */
341   if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
342     gfc_option.warn_std |= GFC_STD_GNU;
343   /* -std=legacy -pedantic is effectively -std=gnu.  */
344   if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
345     gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
346
347   /* If the user didn't explicitly specify -f(no)-second-underscore we
348      use it if we're trying to be compatible with f2c, and not
349      otherwise.  */
350   if (gfc_option.flag_second_underscore == -1)
351     gfc_option.flag_second_underscore = gfc_option.flag_f2c;
352
353   if (!gfc_option.flag_automatic && gfc_option.flag_max_stack_var_size != -2
354       && gfc_option.flag_max_stack_var_size != 0)
355     gfc_warning_now ("Flag -fno-automatic overwrites -fmax-stack-var-size=%d",
356                      gfc_option.flag_max_stack_var_size);
357   else if (!gfc_option.flag_automatic && gfc_option.flag_recursive)
358     gfc_warning_now ("Flag -fno-automatic overwrites -frecursive");
359   else if (!gfc_option.flag_automatic && gfc_option.flag_openmp)
360     gfc_warning_now ("Flag -fno-automatic overwrites -frecursive implied by "
361                      "-fopenmp");
362   else if (gfc_option.flag_max_stack_var_size != -2
363            && gfc_option.flag_recursive)
364     gfc_warning_now ("Flag -frecursive overwrites -fmax-stack-var-size=%d",
365                      gfc_option.flag_max_stack_var_size);
366   else if (gfc_option.flag_max_stack_var_size != -2
367            && gfc_option.flag_openmp)
368     gfc_warning_now ("Flag -fmax-stack-var-size=%d overwrites -frecursive "
369                      "implied by -fopenmp", 
370                      gfc_option.flag_max_stack_var_size);
371
372   /* Implement -frecursive as -fmax-stack-var-size=-1.  */
373   if (gfc_option.flag_recursive)
374     gfc_option.flag_max_stack_var_size = -1;
375
376   /* Implied -frecursive; implemented as -fmax-stack-var-size=-1.  */
377   if (gfc_option.flag_max_stack_var_size == -2 && gfc_option.flag_openmp
378       && gfc_option.flag_automatic)
379     {
380       gfc_option.flag_recursive = 1;
381       gfc_option.flag_max_stack_var_size = -1;
382     }
383
384   /* Set default.  */
385   if (gfc_option.flag_max_stack_var_size == -2)
386     gfc_option.flag_max_stack_var_size = 32768;
387
388   /* Implement -fno-automatic as -fmax-stack-var-size=0.  */
389   if (!gfc_option.flag_automatic)
390     gfc_option.flag_max_stack_var_size = 0;
391   
392   if (pedantic)
393     { 
394       gfc_option.warn_ampersand = 1;
395       gfc_option.warn_tabs = 0;
396     }
397
398   if (pedantic && gfc_option.flag_whole_file)
399     gfc_option.flag_whole_file = 2;
400
401   gfc_cpp_post_options ();
402
403 /* FIXME: return gfc_cpp_preprocess_only ();
404
405    The return value of this function indicates whether the
406    backend needs to be initialized. On -E, we don't need
407    the backend. However, if we return 'true' here, an
408    ICE occurs. Initializing the backend doesn't hurt much,
409    hence, for now we can live with it as is.  */
410   return false;
411 }
412
413
414 /* Set the options for -Wall.  */
415
416 static void
417 set_Wall (int setting)
418 {
419   gfc_option.warn_aliasing = setting;
420   gfc_option.warn_ampersand = setting;
421   gfc_option.warn_conversion = setting;
422   gfc_option.warn_line_truncation = setting;
423   gfc_option.warn_surprising = setting;
424   gfc_option.warn_tabs = !setting;
425   gfc_option.warn_underflow = setting;
426   gfc_option.warn_intrinsic_shadow = setting;
427   gfc_option.warn_intrinsics_std = setting;
428   gfc_option.warn_character_truncation = setting;
429   gfc_option.warn_unused_dummy_argument = setting;
430
431   warn_unused = setting;
432   warn_return_type = setting;
433   warn_switch = setting;
434   warn_uninitialized = setting;
435 }
436
437
438 static void
439 gfc_handle_module_path_options (const char *arg)
440 {
441
442   if (gfc_option.module_dir != NULL)
443     gfc_fatal_error ("gfortran: Only one -J option allowed");
444
445   gfc_option.module_dir = (char *) gfc_getmem (strlen (arg) + 2);
446   strcpy (gfc_option.module_dir, arg);
447   strcat (gfc_option.module_dir, "/");
448
449   gfc_add_include_path (gfc_option.module_dir, true, false);
450 }
451
452
453 static void
454 gfc_handle_fpe_trap_option (const char *arg)
455 {
456   int result, pos = 0, n;
457   static const char * const exception[] = { "invalid", "denormal", "zero",
458                                             "overflow", "underflow",
459                                             "precision", NULL };
460   static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
461                                        GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
462                                        GFC_FPE_UNDERFLOW, GFC_FPE_PRECISION,
463                                        0 };
464  
465   while (*arg)
466     {
467       while (*arg == ',')
468         arg++;
469
470       while (arg[pos] && arg[pos] != ',')
471         pos++;
472
473       result = 0;
474       for (n = 0; exception[n] != NULL; n++)
475         {
476           if (exception[n] && strncmp (exception[n], arg, pos) == 0)
477             {
478               gfc_option.fpe |= opt_exception[n];
479               arg += pos;
480               pos = 0;
481               result = 1;
482               break;
483             }
484         }
485       if (!result)
486         gfc_fatal_error ("Argument to -ffpe-trap is not valid: %s", arg);
487     }
488 }
489
490
491 static void
492 gfc_handle_coarray_option (const char *arg)
493 {
494   if (strcmp (arg, "none") == 0)
495     gfc_option.coarray = GFC_FCOARRAY_NONE;
496   else if (strcmp (arg, "single") == 0)
497     gfc_option.coarray = GFC_FCOARRAY_SINGLE;
498   else
499     gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg);
500 }
501
502
503 static void
504 gfc_handle_runtime_check_option (const char *arg)
505 {
506   int result, pos = 0, n;
507   static const char * const optname[] = { "all", "bounds", "array-temps",
508                                           "recursion", "do", "pointer",
509                                           "mem", NULL };
510   static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
511                                  GFC_RTCHECK_ARRAY_TEMPS,
512                                  GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
513                                  GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
514                                  0 };
515  
516   while (*arg)
517     {
518       while (*arg == ',')
519         arg++;
520
521       while (arg[pos] && arg[pos] != ',')
522         pos++;
523
524       result = 0;
525       for (n = 0; optname[n] != NULL; n++)
526         {
527           if (optname[n] && strncmp (optname[n], arg, pos) == 0)
528             {
529               gfc_option.rtcheck |= optmask[n];
530               arg += pos;
531               pos = 0;
532               result = 1;
533               break;
534             }
535         }
536       if (!result)
537         gfc_fatal_error ("Argument to -fcheck is not valid: %s", arg);
538     }
539 }
540
541
542 /* Handle command-line options.  Returns 0 if unrecognized, 1 if
543    recognized and handled.  */
544
545 int
546 gfc_handle_option (size_t scode, const char *arg, int value,
547                    int kind ATTRIBUTE_UNUSED)
548 {
549   int result = 1;
550   enum opt_code code = (enum opt_code) scode;
551
552   if (gfc_cpp_handle_option (scode, arg, value) == 1)
553     return 1;
554
555   switch (code)
556     {
557     default:
558       result = 0;
559       break;
560
561     case OPT_Wall:
562       set_Wall (value);
563       break;
564
565     case OPT_Waliasing:
566       gfc_option.warn_aliasing = value;
567       break;
568
569     case OPT_Wampersand:
570       gfc_option.warn_ampersand = value;
571       break;
572
573     case OPT_Warray_temporaries:
574       gfc_option.warn_array_temp = value;
575       break;
576
577     case OPT_Wcharacter_truncation:
578       gfc_option.warn_character_truncation = value;
579       break;
580
581     case OPT_Wconversion:
582       gfc_option.warn_conversion = value;
583       break;
584
585     case OPT_Wconversion_extra:
586       gfc_option.warn_conversion_extra = value;
587       break;
588
589     case OPT_Wimplicit_interface:
590       gfc_option.warn_implicit_interface = value;
591       break;
592
593     case OPT_Wimplicit_procedure:
594       gfc_option.warn_implicit_procedure = value;
595       break;
596
597     case OPT_Wline_truncation:
598       gfc_option.warn_line_truncation = value;
599       break;
600
601     case OPT_Wreturn_type:
602       warn_return_type = value;
603       break;
604
605     case OPT_Wsurprising:
606       gfc_option.warn_surprising = value;
607       break;
608
609     case OPT_Wtabs:
610       gfc_option.warn_tabs = value;
611       break;
612
613     case OPT_Wunderflow:
614       gfc_option.warn_underflow = value;
615       break;
616
617     case OPT_Wintrinsic_shadow:
618       gfc_option.warn_intrinsic_shadow = value;
619       break;
620
621     case OPT_Walign_commons:
622       gfc_option.warn_align_commons = value;
623       break;
624
625     case OPT_Wunused_dummy_argument:
626       gfc_option.warn_unused_dummy_argument = value;
627       break;
628
629     case OPT_fall_intrinsics:
630       gfc_option.flag_all_intrinsics = 1;
631       break;
632
633     case OPT_fautomatic:
634       gfc_option.flag_automatic = value;
635       break;
636
637     case OPT_fallow_leading_underscore:
638       gfc_option.flag_allow_leading_underscore = value;
639       break;
640       
641     case OPT_fbackslash:
642       gfc_option.flag_backslash = value;
643       break;
644       
645     case OPT_fbacktrace:
646       gfc_option.flag_backtrace = value;
647       break;
648       
649     case OPT_fcheck_array_temporaries:
650       gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
651       break;
652       
653     case OPT_fdump_core:
654       gfc_option.flag_dump_core = value;
655       break;
656
657     case OPT_fcray_pointer:
658       gfc_option.flag_cray_pointer = value;
659       break;
660
661     case OPT_ff2c:
662       gfc_option.flag_f2c = value;
663       break;
664
665     case OPT_fdollar_ok:
666       gfc_option.flag_dollar_ok = value;
667       break;
668
669     case OPT_fexternal_blas:
670       gfc_option.flag_external_blas = value;
671       break;
672
673     case OPT_fblas_matmul_limit_:
674       gfc_option.blas_matmul_limit = value;
675       break;
676
677     case OPT_fd_lines_as_code:
678       gfc_option.flag_d_lines = 1;
679       break;
680
681     case OPT_fd_lines_as_comments:
682       gfc_option.flag_d_lines = 0;
683       break;
684
685     case OPT_fdump_parse_tree:
686       gfc_option.dump_parse_tree = value;
687       break;
688
689     case OPT_ffixed_form:
690       gfc_option.source_form = FORM_FIXED;
691       break;
692
693     case OPT_ffixed_line_length_none:
694       gfc_option.fixed_line_length = 0;
695       break;
696
697     case OPT_ffixed_line_length_:
698       if (value != 0 && value < 7)
699         gfc_fatal_error ("Fixed line length must be at least seven.");
700       gfc_option.fixed_line_length = value;
701       break;
702
703     case OPT_ffree_form:
704       gfc_option.source_form = FORM_FREE;
705       break;
706
707     case OPT_fopenmp:
708       gfc_option.flag_openmp = value;
709       break;
710
711     case OPT_ffree_line_length_none:
712       gfc_option.free_line_length = 0;
713       break;
714
715     case OPT_ffree_line_length_:
716       if (value != 0 && value < 4)
717         gfc_fatal_error ("Free line length must be at least three.");
718       gfc_option.free_line_length = value;
719       break;
720
721     case OPT_funderscoring:
722       gfc_option.flag_underscoring = value;
723       break;
724
725     case OPT_fwhole_file:
726       gfc_option.flag_whole_file = value;
727       break;
728
729     case OPT_fsecond_underscore:
730       gfc_option.flag_second_underscore = value;
731       break;
732
733     case OPT_static_libgfortran:
734 #ifndef HAVE_LD_STATIC_DYNAMIC
735       gfc_fatal_error ("-static-libgfortran is not supported in this "
736                        "configuration");
737 #endif
738       break;
739
740     case OPT_fimplicit_none:
741       gfc_option.flag_implicit_none = value;
742       break;
743
744     case OPT_fintrinsic_modules_path:
745       gfc_add_include_path (arg, false, false);
746       gfc_add_intrinsic_modules_path (arg);
747       break;
748
749     case OPT_fmax_array_constructor_:
750       gfc_option.flag_max_array_constructor = value > 65535 ? value : 65535;
751       break;
752
753     case OPT_fmax_errors_:
754       gfc_option.max_errors = value;
755       break;
756
757     case OPT_fmax_stack_var_size_:
758       gfc_option.flag_max_stack_var_size = value;
759       break;
760
761     case OPT_fmodule_private:
762       gfc_option.flag_module_private = value;
763       break;
764       
765     case OPT_frange_check:
766       gfc_option.flag_range_check = value;
767       break;
768
769     case OPT_fpack_derived:
770       gfc_option.flag_pack_derived = value;
771       break;
772
773     case OPT_frepack_arrays:
774       gfc_option.flag_repack_arrays = value;
775       break;
776
777     case OPT_fpreprocessed:
778       gfc_option.flag_preprocessed = value;
779       break;
780
781     case OPT_fmax_identifier_length_:
782       if (value > GFC_MAX_SYMBOL_LEN)
783         gfc_fatal_error ("Maximum supported identifier length is %d",
784                          GFC_MAX_SYMBOL_LEN);
785       gfc_option.max_identifier_length = value;
786       break;
787
788     case OPT_fdefault_integer_8:
789       gfc_option.flag_default_integer = value;
790       break;
791
792     case OPT_fdefault_real_8:
793       gfc_option.flag_default_real = value;
794       break;
795
796     case OPT_fdefault_double_8:
797       gfc_option.flag_default_double = value;
798       break;
799
800     case OPT_finit_local_zero:
801       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
802       gfc_option.flag_init_integer_value = 0;
803       gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
804       gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
805       gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
806       gfc_option.flag_init_character_value = (char)0;
807       break;
808
809     case OPT_finit_logical_:
810       if (!strcasecmp (arg, "false"))
811         gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
812       else if (!strcasecmp (arg, "true"))
813         gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
814       else
815         gfc_fatal_error ("Unrecognized option to -finit-logical: %s",
816                          arg);
817       break;
818
819     case OPT_finit_real_:
820       if (!strcasecmp (arg, "zero"))
821         gfc_option.flag_init_real = GFC_INIT_REAL_ZERO;
822       else if (!strcasecmp (arg, "nan"))
823         gfc_option.flag_init_real = GFC_INIT_REAL_NAN;
824       else if (!strcasecmp (arg, "snan"))
825         gfc_option.flag_init_real = GFC_INIT_REAL_SNAN;
826       else if (!strcasecmp (arg, "inf"))
827         gfc_option.flag_init_real = GFC_INIT_REAL_INF;
828       else if (!strcasecmp (arg, "-inf"))
829         gfc_option.flag_init_real = GFC_INIT_REAL_NEG_INF;
830       else
831         gfc_fatal_error ("Unrecognized option to -finit-real: %s",
832                          arg);
833       break;
834
835     case OPT_finit_integer_:
836       gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
837       gfc_option.flag_init_integer_value = atoi (arg);
838       break;
839
840     case OPT_finit_character_:
841       if (value >= 0 && value <= 127)
842         {
843           gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
844           gfc_option.flag_init_character_value = (char)value;
845         }
846       else
847         gfc_fatal_error ("The value of n in -finit-character=n must be "
848                          "between 0 and 127");
849       break;
850
851     case OPT_I:
852       gfc_add_include_path (arg, true, false);
853       break;
854
855     case OPT_J:
856       gfc_handle_module_path_options (arg);
857       break;
858
859     case OPT_fsign_zero:
860       gfc_option.flag_sign_zero = value;
861       break;
862
863     case OPT_ffpe_trap_:
864       gfc_handle_fpe_trap_option (arg);
865       break;
866
867     case OPT_std_f95:
868       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
869                              | GFC_STD_F2008_OBS;
870       gfc_option.warn_std = GFC_STD_F95_OBS;
871       gfc_option.max_continue_fixed = 19;
872       gfc_option.max_continue_free = 39;
873       gfc_option.max_identifier_length = 31;
874       gfc_option.warn_ampersand = 1;
875       gfc_option.warn_tabs = 0;
876       break;
877
878     case OPT_std_f2003:
879       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
880         | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
881       gfc_option.warn_std = GFC_STD_F95_OBS;
882       gfc_option.max_identifier_length = 63;
883       gfc_option.warn_ampersand = 1;
884       gfc_option.warn_tabs = 0;
885       break;
886
887     case OPT_std_f2008:
888       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
889         | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
890       gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
891       gfc_option.max_identifier_length = 63;
892       gfc_option.warn_ampersand = 1;
893       gfc_option.warn_tabs = 0;
894       break;
895
896     case OPT_std_gnu:
897       set_default_std_flags ();
898       break;
899
900     case OPT_std_legacy:
901       set_default_std_flags ();
902       gfc_option.warn_std = 0;
903       break;
904
905     case OPT_Wintrinsics_std:
906       gfc_option.warn_intrinsics_std = value;
907       break;
908
909     case OPT_fshort_enums:
910       /* Handled in language-independent code.  */
911       break;
912
913     case OPT_fconvert_little_endian:
914       gfc_option.convert = GFC_CONVERT_LITTLE;
915       break;
916
917     case OPT_fconvert_big_endian:
918       gfc_option.convert = GFC_CONVERT_BIG;
919       break;
920
921     case OPT_fconvert_native:
922       gfc_option.convert = GFC_CONVERT_NATIVE;
923       break;
924
925     case OPT_fconvert_swap:
926       gfc_option.convert = GFC_CONVERT_SWAP;
927       break;
928
929     case OPT_frecord_marker_4:
930       gfc_option.record_marker = 4;
931       break;
932
933     case OPT_frecord_marker_8:
934       gfc_option.record_marker = 8;
935       break;
936
937     case OPT_fmax_subrecord_length_:
938       if (value > MAX_SUBRECORD_LENGTH)
939         gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
940                          MAX_SUBRECORD_LENGTH);
941
942       gfc_option.max_subrecord_length = value;
943       break;
944
945     case OPT_frecursive:
946       gfc_option.flag_recursive = value;
947       break;
948
949     case OPT_falign_commons:
950       gfc_option.flag_align_commons = value;
951       break;
952
953     case OPT_fprotect_parens:
954       gfc_option.flag_protect_parens = value;
955       break;
956
957     case OPT_fcheck_:
958       gfc_handle_runtime_check_option (arg);
959       break;
960
961     case OPT_fcoarray_:
962       gfc_handle_coarray_option (arg);
963       break;
964     }
965
966   return result;
967 }