]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/options.c
re PR fortran/68829 (Segfaults with -Ofast due to large array on stack)
[thirdparty/gcc.git] / gcc / fortran / options.c
1 /* Parse and display command line options.
2 Copyright (C) 2000-2017 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "target.h"
25 #include "tree.h"
26 #include "gfortran.h"
27 #include "diagnostic.h" /* For global_dc. */
28 #include "opts.h"
29 #include "toplev.h" /* For save_decoded_options. */
30 #include "cpp.h"
31 #include "langhooks.h"
32
33 gfc_option_t gfc_option;
34
35
36 /* Set flags that control warnings and errors for different
37 Fortran standards to their default values. Keep in sync with
38 libgfortran/runtime/compile_options.c (init_compile_options). */
39
40 static void
41 set_default_std_flags (void)
42 {
43 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
44 | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
45 | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY;
46 gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
47 }
48
49
50 /* Set all the DEC extension flags. */
51
52 static void
53 set_dec_flags (int value)
54 {
55 /* Allow legacy code without warnings. */
56 gfc_option.allow_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL
57 | GFC_STD_GNU | GFC_STD_LEGACY;
58 gfc_option.warn_std &= ~(GFC_STD_LEGACY | GFC_STD_F95_DEL);
59
60 /* Set -fd-lines-as-comments by default. */
61 if (value && gfc_current_form != FORM_FREE && gfc_option.flag_d_lines == -1)
62 gfc_option.flag_d_lines = 0;
63
64 /* Set other DEC compatibility extensions. */
65 flag_dollar_ok |= value;
66 flag_cray_pointer |= value;
67 flag_dec_structure |= value;
68 flag_dec_intrinsic_ints |= value;
69 flag_dec_static |= value;
70 flag_dec_math |= value;
71 }
72
73
74 /* Return language mask for Fortran options. */
75
76 unsigned int
77 gfc_option_lang_mask (void)
78 {
79 return CL_Fortran;
80 }
81
82 /* Initialize options structure OPTS. */
83
84 void
85 gfc_init_options_struct (struct gcc_options *opts)
86 {
87 opts->x_flag_errno_math = 0;
88 opts->frontend_set_flag_errno_math = true;
89 opts->x_flag_associative_math = -1;
90 opts->frontend_set_flag_associative_math = true;
91 }
92
93 /* Get ready for options handling. Keep in sync with
94 libgfortran/runtime/compile_options.c (init_compile_options). */
95
96 void
97 gfc_init_options (unsigned int decoded_options_count,
98 struct cl_decoded_option *decoded_options)
99 {
100 gfc_source_file = NULL;
101 gfc_option.module_dir = NULL;
102 gfc_option.source_form = FORM_UNKNOWN;
103 gfc_option.max_continue_fixed = 255;
104 gfc_option.max_continue_free = 255;
105 gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
106 gfc_option.max_errors = 25;
107
108 gfc_option.flag_preprocessed = 0;
109 gfc_option.flag_d_lines = -1;
110 gfc_option.flag_init_integer = GFC_INIT_INTEGER_OFF;
111 gfc_option.flag_init_integer_value = 0;
112 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_OFF;
113 gfc_option.flag_init_character = GFC_INIT_CHARACTER_OFF;
114 gfc_option.flag_init_character_value = (char)0;
115
116 gfc_option.fpe = 0;
117 /* All except GFC_FPE_INEXACT. */
118 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
119 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
120 | GFC_FPE_UNDERFLOW;
121 gfc_option.rtcheck = 0;
122
123 /* ??? Wmissing-include-dirs is disabled by default in C/C++ but
124 enabled by default in Fortran. Ideally, we should express this
125 in .opt, but that is not supported yet. */
126 if (!global_options_set.x_cpp_warn_missing_include_dirs)
127 global_options.x_cpp_warn_missing_include_dirs = 1;
128
129 set_dec_flags (0);
130
131 set_default_std_flags ();
132
133 /* Initialize cpp-related options. */
134 gfc_cpp_init_options (decoded_options_count, decoded_options);
135 gfc_diagnostics_init ();
136 }
137
138
139 /* Determine the source form from the filename extension. We assume
140 case insensitivity. */
141
142 static gfc_source_form
143 form_from_filename (const char *filename)
144 {
145 static const struct
146 {
147 const char *extension;
148 gfc_source_form form;
149 }
150 exttype[] =
151 {
152 {
153 ".f90", FORM_FREE}
154 ,
155 {
156 ".f95", FORM_FREE}
157 ,
158 {
159 ".f03", FORM_FREE}
160 ,
161 {
162 ".f08", FORM_FREE}
163 ,
164 {
165 ".f", FORM_FIXED}
166 ,
167 {
168 ".for", FORM_FIXED}
169 ,
170 {
171 ".ftn", FORM_FIXED}
172 ,
173 {
174 "", FORM_UNKNOWN}
175 }; /* sentinel value */
176
177 gfc_source_form f_form;
178 const char *fileext;
179 int i;
180
181 /* Find end of file name. Note, filename is either a NULL pointer or
182 a NUL terminated string. */
183 i = 0;
184 while (filename[i] != '\0')
185 i++;
186
187 /* Find last period. */
188 while (i >= 0 && (filename[i] != '.'))
189 i--;
190
191 /* Did we see a file extension? */
192 if (i < 0)
193 return FORM_UNKNOWN; /* Nope */
194
195 /* Get file extension and compare it to others. */
196 fileext = &(filename[i]);
197
198 i = -1;
199 f_form = FORM_UNKNOWN;
200 do
201 {
202 i++;
203 if (strcasecmp (fileext, exttype[i].extension) == 0)
204 {
205 f_form = exttype[i].form;
206 break;
207 }
208 }
209 while (exttype[i].form != FORM_UNKNOWN);
210
211 return f_form;
212 }
213
214
215 /* Finalize commandline options. */
216
217 bool
218 gfc_post_options (const char **pfilename)
219 {
220 const char *filename = *pfilename, *canon_source_file = NULL;
221 char *source_path;
222 int i;
223
224 /* Excess precision other than "fast" requires front-end
225 support. */
226 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
227 sorry ("-fexcess-precision=standard for Fortran");
228 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
229
230 /* Fortran allows associative math - but we cannot reassociate if
231 we want traps or signed zeros. Cf. also flag_protect_parens. */
232 if (flag_associative_math == -1)
233 flag_associative_math = (!flag_trapping_math && !flag_signed_zeros);
234
235 if (flag_protect_parens == -1)
236 flag_protect_parens = !optimize_fast;
237
238 /* -Ofast sets implies -fstack-arrays unless an explicit size is set for
239 stack arrays. */
240 if (flag_stack_arrays == -1 && flag_max_stack_var_size == -2)
241 flag_stack_arrays = optimize_fast;
242
243 /* By default, disable (re)allocation during assignment for -std=f95,
244 and enable it for F2003/F2008/GNU/Legacy. */
245 if (flag_realloc_lhs == -1)
246 {
247 if (gfc_option.allow_std & GFC_STD_F2003)
248 flag_realloc_lhs = 1;
249 else
250 flag_realloc_lhs = 0;
251 }
252
253 /* -fbounds-check is equivalent to -fcheck=bounds */
254 if (flag_bounds_check)
255 gfc_option.rtcheck |= GFC_RTCHECK_BOUNDS;
256
257 if (flag_compare_debug)
258 flag_dump_fortran_original = 0;
259
260 /* Make -fmax-errors visible to gfortran's diagnostic machinery. */
261 if (global_options_set.x_flag_max_errors)
262 gfc_option.max_errors = flag_max_errors;
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, true);
298 }
299 else
300 gfc_add_include_path (".", true, true, true);
301
302 if (canon_source_file != gfc_source_file)
303 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 (0, "Reading file %qs 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 (0, "%<-fd-lines-as-comments%> has no effect "
327 "in free form");
328 else if (gfc_option.flag_d_lines == 1)
329 gfc_warning_now (0, "%<-fd-lines-as-code%> has no effect in free form");
330
331 if (warn_line_truncation == -1)
332 warn_line_truncation = 1;
333
334 /* Enable -Werror=line-truncation when -Werror and -Wno-error have
335 not been set. */
336 if (warn_line_truncation && !global_options_set.x_warnings_are_errors
337 && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
338 DK_UNSPECIFIED))
339 diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
340 DK_ERROR, UNKNOWN_LOCATION);
341 }
342 else if (warn_line_truncation == -1)
343 warn_line_truncation = 0;
344
345 /* If -pedantic, warn about the use of GNU extensions. */
346 if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
347 gfc_option.warn_std |= GFC_STD_GNU;
348 /* -std=legacy -pedantic is effectively -std=gnu. */
349 if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
350 gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
351
352 /* If the user didn't explicitly specify -f(no)-second-underscore we
353 use it if we're trying to be compatible with f2c, and not
354 otherwise. */
355 if (flag_second_underscore == -1)
356 flag_second_underscore = flag_f2c;
357
358 if (!flag_automatic && flag_max_stack_var_size != -2
359 && flag_max_stack_var_size != 0)
360 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-fmax-stack-var-size=%d%>",
361 flag_max_stack_var_size);
362 else if (!flag_automatic && flag_recursive)
363 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%>");
364 else if (!flag_automatic && flag_openmp)
365 gfc_warning_now (0, "Flag %<-fno-automatic%> overwrites %<-frecursive%> implied by "
366 "%<-fopenmp%>");
367 else if (flag_max_stack_var_size != -2 && flag_recursive)
368 gfc_warning_now (0, "Flag %<-frecursive%> overwrites %<-fmax-stack-var-size=%d%>",
369 flag_max_stack_var_size);
370 else if (flag_max_stack_var_size != -2 && flag_openmp)
371 gfc_warning_now (0, "Flag %<-fmax-stack-var-size=%d%> overwrites %<-frecursive%> "
372 "implied by %<-fopenmp%>", flag_max_stack_var_size);
373
374 /* Implement -frecursive as -fmax-stack-var-size=-1. */
375 if (flag_recursive)
376 flag_max_stack_var_size = -1;
377
378 /* Implied -frecursive; implemented as -fmax-stack-var-size=-1. */
379 if (flag_max_stack_var_size == -2 && flag_openmp && flag_automatic)
380 {
381 flag_recursive = 1;
382 flag_max_stack_var_size = -1;
383 }
384
385 /* Set flag_stack_arrays correctly. */
386 if (flag_stack_arrays == -1)
387 flag_stack_arrays = 0;
388
389 /* Set default. */
390 if (flag_max_stack_var_size == -2)
391 flag_max_stack_var_size = 32768;
392
393 /* Implement -fno-automatic as -fmax-stack-var-size=0. */
394 if (!flag_automatic)
395 flag_max_stack_var_size = 0;
396
397 /* If the user did not specify an inline matmul limit, inline up to the BLAS
398 limit or up to 30 if no external BLAS is specified. */
399
400 if (flag_inline_matmul_limit < 0)
401 {
402 if (flag_external_blas)
403 flag_inline_matmul_limit = flag_blas_matmul_limit;
404 else
405 flag_inline_matmul_limit = 30;
406 }
407
408 /* Optimization implies front end optimization, unless the user
409 specified it directly. */
410
411 if (flag_frontend_optimize == -1)
412 flag_frontend_optimize = optimize;
413
414 if (flag_max_array_constructor < 65535)
415 flag_max_array_constructor = 65535;
416
417 if (flag_fixed_line_length != 0 && flag_fixed_line_length < 7)
418 gfc_fatal_error ("Fixed line length must be at least seven");
419
420 if (flag_free_line_length != 0 && flag_free_line_length < 4)
421 gfc_fatal_error ("Free line length must be at least three");
422
423 if (flag_max_subrecord_length > MAX_SUBRECORD_LENGTH)
424 gfc_fatal_error ("Maximum subrecord length cannot exceed %d",
425 MAX_SUBRECORD_LENGTH);
426
427 gfc_cpp_post_options ();
428
429 if (gfc_option.allow_std & GFC_STD_F2008)
430 lang_hooks.name = "GNU Fortran2008";
431 else if (gfc_option.allow_std & GFC_STD_F2003)
432 lang_hooks.name = "GNU Fortran2003";
433
434 return gfc_cpp_preprocess_only ();
435 }
436
437
438 static void
439 gfc_handle_module_path_options (const char *arg)
440 {
441
442 if (gfc_option.module_dir != NULL)
443 gfc_fatal_error ("gfortran: Only one %<-J%> option allowed");
444
445 gfc_option.module_dir = XCNEWVEC (char, strlen (arg) + 2);
446 strcpy (gfc_option.module_dir, arg);
447
448 gfc_add_include_path (gfc_option.module_dir, true, false, true);
449
450 strcat (gfc_option.module_dir, "/");
451 }
452
453
454 /* Handle options -ffpe-trap= and -ffpe-summary=. */
455
456 static void
457 gfc_handle_fpe_option (const char *arg, bool trap)
458 {
459 int result, pos = 0, n;
460 /* precision is a backwards compatibility alias for inexact. */
461 static const char * const exception[] = { "invalid", "denormal", "zero",
462 "overflow", "underflow",
463 "inexact", "precision", NULL };
464 static const int opt_exception[] = { GFC_FPE_INVALID, GFC_FPE_DENORMAL,
465 GFC_FPE_ZERO, GFC_FPE_OVERFLOW,
466 GFC_FPE_UNDERFLOW, GFC_FPE_INEXACT,
467 GFC_FPE_INEXACT,
468 0 };
469
470 /* As the default for -ffpe-summary= is nonzero, set it to 0. */
471 if (!trap)
472 gfc_option.fpe_summary = 0;
473
474 while (*arg)
475 {
476 while (*arg == ',')
477 arg++;
478
479 while (arg[pos] && arg[pos] != ',')
480 pos++;
481
482 result = 0;
483 if (!trap && strncmp ("none", arg, pos) == 0)
484 {
485 gfc_option.fpe_summary = 0;
486 arg += pos;
487 pos = 0;
488 continue;
489 }
490 else if (!trap && strncmp ("all", arg, pos) == 0)
491 {
492 gfc_option.fpe_summary = GFC_FPE_INVALID | GFC_FPE_DENORMAL
493 | GFC_FPE_ZERO | GFC_FPE_OVERFLOW
494 | GFC_FPE_UNDERFLOW | GFC_FPE_INEXACT;
495 arg += pos;
496 pos = 0;
497 continue;
498 }
499 else
500 for (n = 0; exception[n] != NULL; n++)
501 {
502 if (exception[n] && strncmp (exception[n], arg, pos) == 0)
503 {
504 if (trap)
505 gfc_option.fpe |= opt_exception[n];
506 else
507 gfc_option.fpe_summary |= opt_exception[n];
508 arg += pos;
509 pos = 0;
510 result = 1;
511 break;
512 }
513 }
514 if (!result && !trap)
515 gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg);
516 else if (!result)
517 gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg);
518
519 }
520 }
521
522
523 static void
524 gfc_handle_runtime_check_option (const char *arg)
525 {
526 int result, pos = 0, n;
527 static const char * const optname[] = { "all", "bounds", "array-temps",
528 "recursion", "do", "pointer",
529 "mem", NULL };
530 static const int optmask[] = { GFC_RTCHECK_ALL, GFC_RTCHECK_BOUNDS,
531 GFC_RTCHECK_ARRAY_TEMPS,
532 GFC_RTCHECK_RECURSION, GFC_RTCHECK_DO,
533 GFC_RTCHECK_POINTER, GFC_RTCHECK_MEM,
534 0 };
535
536 while (*arg)
537 {
538 while (*arg == ',')
539 arg++;
540
541 while (arg[pos] && arg[pos] != ',')
542 pos++;
543
544 result = 0;
545 for (n = 0; optname[n] != NULL; n++)
546 {
547 if (optname[n] && strncmp (optname[n], arg, pos) == 0)
548 {
549 gfc_option.rtcheck |= optmask[n];
550 arg += pos;
551 pos = 0;
552 result = 1;
553 break;
554 }
555 else if (optname[n] && pos > 3 && strncmp ("no-", arg, 3) == 0
556 && strncmp (optname[n], arg+3, pos-3) == 0)
557 {
558 gfc_option.rtcheck &= ~optmask[n];
559 arg += pos;
560 pos = 0;
561 result = 1;
562 break;
563 }
564 }
565 if (!result)
566 gfc_fatal_error ("Argument to %<-fcheck%> is not valid: %s", arg);
567 }
568 }
569
570
571 /* Handle command-line options. Returns 0 if unrecognized, 1 if
572 recognized and handled. */
573
574 bool
575 gfc_handle_option (size_t scode, const char *arg, int value,
576 int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
577 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
578 {
579 bool result = true;
580 enum opt_code code = (enum opt_code) scode;
581
582 if (gfc_cpp_handle_option (scode, arg, value) == 1)
583 return true;
584
585 switch (code)
586 {
587 default:
588 if (cl_options[code].flags & gfc_option_lang_mask ())
589 break;
590 result = false;
591 break;
592
593 case OPT_fcheck_array_temporaries:
594 gfc_option.rtcheck |= GFC_RTCHECK_ARRAY_TEMPS;
595 break;
596
597 case OPT_fd_lines_as_code:
598 gfc_option.flag_d_lines = 1;
599 break;
600
601 case OPT_fd_lines_as_comments:
602 gfc_option.flag_d_lines = 0;
603 break;
604
605 case OPT_ffixed_form:
606 gfc_option.source_form = FORM_FIXED;
607 break;
608
609 case OPT_ffree_form:
610 gfc_option.source_form = FORM_FREE;
611 break;
612
613 case OPT_static_libgfortran:
614 #ifndef HAVE_LD_STATIC_DYNAMIC
615 gfc_fatal_error ("%<-static-libgfortran%> is not supported in this "
616 "configuration");
617 #endif
618 break;
619
620 case OPT_fintrinsic_modules_path:
621 case OPT_fintrinsic_modules_path_:
622
623 /* This is needed because omp_lib.h is in a directory together
624 with intrinsic modules. Do no warn because during testing
625 without an installed compiler, we would get lots of bogus
626 warnings for a missing include directory. */
627 gfc_add_include_path (arg, false, false, false);
628
629 gfc_add_intrinsic_modules_path (arg);
630 break;
631
632 case OPT_fpreprocessed:
633 gfc_option.flag_preprocessed = value;
634 break;
635
636 case OPT_fmax_identifier_length_:
637 if (value > GFC_MAX_SYMBOL_LEN)
638 gfc_fatal_error ("Maximum supported identifier length is %d",
639 GFC_MAX_SYMBOL_LEN);
640 gfc_option.max_identifier_length = value;
641 break;
642
643 case OPT_finit_local_zero:
644 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
645 gfc_option.flag_init_integer_value = 0;
646 flag_init_real = GFC_INIT_REAL_ZERO;
647 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
648 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
649 gfc_option.flag_init_character_value = (char)0;
650 break;
651
652 case OPT_finit_logical_:
653 if (!strcasecmp (arg, "false"))
654 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_FALSE;
655 else if (!strcasecmp (arg, "true"))
656 gfc_option.flag_init_logical = GFC_INIT_LOGICAL_TRUE;
657 else
658 gfc_fatal_error ("Unrecognized option to %<-finit-logical%>: %s",
659 arg);
660 break;
661
662 case OPT_finit_integer_:
663 gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
664 gfc_option.flag_init_integer_value = atoi (arg);
665 break;
666
667 case OPT_finit_character_:
668 if (value >= 0 && value <= 127)
669 {
670 gfc_option.flag_init_character = GFC_INIT_CHARACTER_ON;
671 gfc_option.flag_init_character_value = (char)value;
672 }
673 else
674 gfc_fatal_error ("The value of n in %<-finit-character=n%> must be "
675 "between 0 and 127");
676 break;
677
678 case OPT_I:
679 gfc_add_include_path (arg, true, false, true);
680 break;
681
682 case OPT_J:
683 gfc_handle_module_path_options (arg);
684 break;
685
686 case OPT_ffpe_trap_:
687 gfc_handle_fpe_option (arg, true);
688 break;
689
690 case OPT_ffpe_summary_:
691 gfc_handle_fpe_option (arg, false);
692 break;
693
694 case OPT_std_f95:
695 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77
696 | GFC_STD_F2008_OBS;
697 gfc_option.warn_std = GFC_STD_F95_OBS;
698 gfc_option.max_continue_fixed = 19;
699 gfc_option.max_continue_free = 39;
700 gfc_option.max_identifier_length = 31;
701 warn_ampersand = 1;
702 warn_tabs = 1;
703 break;
704
705 case OPT_std_f2003:
706 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
707 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS;
708 gfc_option.warn_std = GFC_STD_F95_OBS;
709 gfc_option.max_identifier_length = 63;
710 warn_ampersand = 1;
711 warn_tabs = 1;
712 break;
713
714 case OPT_std_f2008:
715 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
716 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS;
717 gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
718 gfc_option.max_identifier_length = 63;
719 warn_ampersand = 1;
720 warn_tabs = 1;
721 break;
722
723 case OPT_std_f2008ts:
724 gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
725 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
726 | GFC_STD_F2008_TS;
727 gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
728 gfc_option.max_identifier_length = 63;
729 warn_ampersand = 1;
730 warn_tabs = 1;
731 break;
732
733 case OPT_std_gnu:
734 set_default_std_flags ();
735 break;
736
737 case OPT_std_legacy:
738 set_default_std_flags ();
739 gfc_option.warn_std = 0;
740 break;
741
742 case OPT_fshort_enums:
743 /* Handled in language-independent code. */
744 break;
745
746 case OPT_fcheck_:
747 gfc_handle_runtime_check_option (arg);
748 break;
749
750 case OPT_fdec:
751 /* Enable all DEC extensions. */
752 set_dec_flags (1);
753 break;
754
755 case OPT_fdec_structure:
756 flag_dec_structure = 1;
757 break;
758 }
759
760 Fortran_handle_option_auto (&global_options, &global_options_set,
761 scode, arg, value,
762 gfc_option_lang_mask (), kind,
763 loc, handlers, global_dc);
764 return result;
765 }
766
767
768 /* Return a string with the options passed to the compiler; used for
769 Fortran's compiler_options() intrinsic. */
770
771 char *
772 gfc_get_option_string (void)
773 {
774 unsigned j;
775 size_t len, pos;
776 char *result;
777
778 /* Allocate and return a one-character string with '\0'. */
779 if (!save_decoded_options_count)
780 return XCNEWVEC (char, 1);
781
782 /* Determine required string length. */
783
784 len = 0;
785 for (j = 1; j < save_decoded_options_count; j++)
786 {
787 switch (save_decoded_options[j].opt_index)
788 {
789 case OPT_o:
790 case OPT_d:
791 case OPT_dumpbase:
792 case OPT_dumpdir:
793 case OPT_auxbase:
794 case OPT_quiet:
795 case OPT_version:
796 case OPT_fintrinsic_modules_path:
797 case OPT_fintrinsic_modules_path_:
798 /* Ignore these. */
799 break;
800 default:
801 /* Ignore file names. */
802 if (save_decoded_options[j].orig_option_with_args_text[0] == '-')
803 len += 1
804 + strlen (save_decoded_options[j].orig_option_with_args_text);
805 }
806 }
807
808 result = XCNEWVEC (char, len);
809
810 pos = 0;
811 for (j = 1; j < save_decoded_options_count; j++)
812 {
813 switch (save_decoded_options[j].opt_index)
814 {
815 case OPT_o:
816 case OPT_d:
817 case OPT_dumpbase:
818 case OPT_dumpdir:
819 case OPT_auxbase:
820 case OPT_quiet:
821 case OPT_version:
822 case OPT_fintrinsic_modules_path:
823 case OPT_fintrinsic_modules_path_:
824 /* Ignore these. */
825 continue;
826
827 case OPT_cpp_:
828 /* Use "-cpp" rather than "-cpp=<temporary file>". */
829 len = 4;
830 break;
831
832 default:
833 /* Ignore file names. */
834 if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
835 continue;
836
837 len = strlen (save_decoded_options[j].orig_option_with_args_text);
838 }
839
840 memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len);
841 pos += len;
842 result[pos++] = ' ';
843 }
844
845 result[--pos] = '\0';
846 return result;
847 }