OSDN Git Service

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