OSDN Git Service

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