OSDN Git Service

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