OSDN Git Service

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