OSDN Git Service

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