1 /* Parse and display command line options.
2 Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Andy Vaught
5 This file is part of GNU G95.
7 GNU G95 is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU G95 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU G95; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
27 #include "coretypes.h"
33 #include "tree-inline.h"
37 gfc_option_t gfc_option
;
40 /* Get ready for options handling. */
43 gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED
,
44 const char **argv ATTRIBUTE_UNUSED
)
47 gfc_option
.source
= NULL
;
48 gfc_option
.module_dir
= NULL
;
49 gfc_option
.source_form
= FORM_UNKNOWN
;
50 gfc_option
.fixed_line_length
= 72;
51 gfc_option
.max_identifier_length
= GFC_MAX_SYMBOL_LEN
;
52 gfc_option
.verbose
= 0;
54 gfc_option
.warn_aliasing
= 0;
55 gfc_option
.warn_conversion
= 0;
56 gfc_option
.warn_implicit_interface
= 0;
57 gfc_option
.warn_line_truncation
= 0;
58 gfc_option
.warn_surprising
= 0;
59 gfc_option
.warn_unused_labels
= 0;
61 gfc_option
.flag_dollar_ok
= 0;
62 gfc_option
.flag_underscoring
= 1;
63 gfc_option
.flag_second_underscore
= 1;
64 gfc_option
.flag_implicit_none
= 0;
65 gfc_option
.flag_max_stack_var_size
= 32768;
66 gfc_option
.flag_module_access_private
= 0;
67 gfc_option
.flag_no_backend
= 0;
68 gfc_option
.flag_pack_derived
= 0;
69 gfc_option
.flag_repack_arrays
= 0;
71 gfc_option
.q_kind
= gfc_default_double_kind ();
76 flag_argument_noalias
= 2;
78 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
79 | GFC_STD_F2003_OBS
| GFC_STD_F2003_DEL
| GFC_STD_F2003
| GFC_STD_GNU
;
80 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
81 | GFC_STD_F2003
| GFC_STD_GNU
;
87 /* Finalize commandline options. */
90 gfc_post_options (const char **pfilename
)
92 const char *filename
= *pfilename
;
94 /* Verify the input file name. */
95 if (!filename
|| strcmp (filename
, "-") == 0)
100 gfc_option
.source
= filename
;
102 flag_inline_trees
= 1;
104 /* Use tree inlining. */
107 if (flag_inline_functions
)
109 flag_inline_trees
= 2;
110 flag_inline_functions
= 0;
117 /* Set the options for -Wall. */
123 gfc_option
.warn_aliasing
= 1;
124 gfc_option
.warn_line_truncation
= 1;
125 gfc_option
.warn_surprising
= 1;
126 gfc_option
.warn_unused_labels
= 1;
129 warn_return_type
= 1;
132 /* We save the value of warn_uninitialized, since if they put
133 -Wuninitialized on the command line, we need to generate a
134 warning about not using it without also specifying -O. */
136 if (warn_uninitialized
!= 1)
137 warn_uninitialized
= 2;
142 gfc_handle_module_path_options (const char *arg
)
145 if (gfc_option
.module_dir
!= NULL
)
147 gfc_status ("gfortran: Only one -M option allowed\n");
153 gfc_status ("gfortran: Directory required after -M\n");
157 gfc_option
.module_dir
= (char *) gfc_getmem (strlen (arg
));
158 strcpy (gfc_option
.module_dir
, arg
);
159 strcat (gfc_option
.module_dir
, "/");
162 /* Handle command-line options. Returns 0 if unrecognized, 1 if
163 recognized and handled. */
165 gfc_handle_option (size_t scode
, const char *arg
, int value
)
168 enum opt_code code
= (enum opt_code
) scode
;
170 /* Ignore file names. */
185 gfc_option
.warn_aliasing
= value
;
188 case OPT_Wconversion
:
189 gfc_option
.warn_conversion
= value
;
192 case OPT_Wimplicit_interface
:
193 gfc_option
.warn_implicit_interface
= value
;
196 case OPT_Wline_truncation
:
197 gfc_option
.warn_line_truncation
= value
;
200 case OPT_Wsurprising
:
201 gfc_option
.warn_surprising
= value
;
204 case OPT_Wunused_labels
:
205 gfc_option
.warn_unused_labels
= value
;
209 gfc_option
.flag_dollar_ok
= value
;
212 case OPT_fdump_parse_tree
:
213 gfc_option
.verbose
= value
;
216 case OPT_ffixed_form
:
217 gfc_option
.source_form
= FORM_FIXED
;
221 gfc_option
.source_form
= FORM_FREE
;
224 case OPT_funderscoring
:
225 gfc_option
.flag_underscoring
= value
;
228 case OPT_fsecond_underscore
:
229 gfc_option
.flag_second_underscore
= value
;
232 case OPT_fimplicit_none
:
233 gfc_option
.flag_implicit_none
= value
;
236 case OPT_fmax_stack_var_size_
:
237 gfc_option
.flag_max_stack_var_size
= value
;
240 case OPT_fmodule_private
:
241 gfc_option
.flag_module_access_private
= value
;
244 case OPT_fno_backend
:
245 gfc_option
.flag_no_backend
= value
;
248 case OPT_fpack_derived
:
249 gfc_option
.flag_pack_derived
= value
;
252 case OPT_frepack_arrays
:
253 gfc_option
.flag_repack_arrays
= value
;
256 case OPT_ffixed_line_length_80
:
257 gfc_option
.fixed_line_length
= 80;
260 case OPT_ffixed_line_length_132
:
261 gfc_option
.fixed_line_length
= 132;
264 case OPT_fmax_identifier_length_
:
265 if (value
> GFC_MAX_SYMBOL_LEN
)
266 gfc_fatal_error ("Maximum supported idenitifier length is %d",
268 gfc_option
.max_identifier_length
= value
;
272 if (gfc_validate_kind (BT_REAL
, value
) < 0)
273 gfc_fatal_error ("Argument to -fqkind isn't a valid real kind");
274 gfc_option
.q_kind
= value
;
278 gfc_option
.i8
= value
;
282 gfc_option
.r8
= value
;
286 gfc_option
.d8
= value
;
290 gfc_add_include_path (arg
);
295 gfc_handle_module_path_options (arg
);
298 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F2003_OBS
300 gfc_option
.warn_std
= GFC_STD_F95_OBS
;
301 gfc_option
.max_identifier_length
= 31;
305 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F2003_OBS
307 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F2003_OBS
;
308 gfc_option
.max_identifier_length
= 63;
312 gfc_option
.allow_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
313 | GFC_STD_F2003_OBS
| GFC_STD_F2003_DEL
| GFC_STD_F2003
| GFC_STD_GNU
;
314 gfc_option
.warn_std
= GFC_STD_F95_OBS
| GFC_STD_F95_DEL
315 | GFC_STD_F2003_OBS
| GFC_STD_F2003_DEL
| GFC_STD_GNU
;