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