OSDN Git Service

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