OSDN Git Service

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