From b86f6cd9ab108f1fda89c4fb00b0b16931182041 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 2 Jul 2003 20:15:46 +0000 Subject: [PATCH] c-common.h (c_common_init_options): New prototype. * c-common.h (c_common_init_options): New prototype. * c-opts.c (deferred_size): Remove. (defer_opt): Array is now pre-allocated. (c_common_init_options): Pre-allocate deferred_opts. Make lang_flags unsigned. (push_command_line_options): Free deferred_opts. * hooks.c (hook_uint_uint_constcharptrptr_0): New. * hooks.h (hook_uint_uint_constcharptrptr_0): New. * langhooks-def.h (LANG_HOOKS_INIT_OPTIONS): Update. * langhooks.h (struct lang_hooks): New prototype for init_options. * main.c (main): Cast argv. * opts.c (handle_option, handle_options): Update prototypes. (decode_options): save_argc, save_argv are not global. Constify. * opts.h (decode_options): New prototype. * toplev.c (general_init): New protoype. (save_argv): Make static. (save_argc): Remove. (print_switch_values, general_init): Constify. (toplev_main): Save argv. * toplev.h (toplev_main): Update prototype. (save_argc, save_argv): Remove. ada: * misc.c (save_argc, save_argv): Make static. (gnat_init_options): New prototype. (gnat_init_options): Update. f: * top.c (ffe_init_options): Update prototype. * top.h (ffe_init_options): Update prototype. java: * lang.c (java_init_options): Update prototype. treelang: * tree1.c (treelang_init_options): Update prototype. * treelang.h (treelang_init_options): Update prototype. From-SVN: r68850 --- gcc/ChangeLog | 24 ++++++++++++++++++++++++ gcc/ada/ChangeLog | 6 ++++++ gcc/ada/misc.c | 23 ++++++++++++++--------- gcc/c-common.h | 2 +- gcc/c-opts.c | 27 +++++++++------------------ gcc/f/ChangeLog | 5 +++++ gcc/f/top.c | 5 +++-- gcc/f/top.h | 2 +- gcc/hooks.c | 7 +++++++ gcc/hooks.h | 2 ++ gcc/java/ChangeLog | 4 ++++ gcc/java/lang.c | 7 ++++--- gcc/langhooks-def.h | 4 ++-- gcc/langhooks.h | 2 +- gcc/main.c | 2 +- gcc/opts.c | 20 ++++++++------------ gcc/opts.h | 2 +- gcc/toplev.c | 17 +++++++++-------- gcc/toplev.h | 6 +----- gcc/treelang/ChangeLog | 5 +++++ gcc/treelang/tree1.c | 5 +++-- gcc/treelang/treetree.h | 2 +- 22 files changed, 112 insertions(+), 67 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 435a0c2..d18086a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2003-07-02 Neil Booth + + * c-common.h (c_common_init_options): New prototype. + * c-opts.c (deferred_size): Remove. + (defer_opt): Array is now pre-allocated. + (c_common_init_options): Pre-allocate deferred_opts. Make + lang_flags unsigned. + (push_command_line_options): Free deferred_opts. + * hooks.c (hook_uint_uint_constcharptrptr_0): New. + * hooks.h (hook_uint_uint_constcharptrptr_0): New. + * langhooks-def.h (LANG_HOOKS_INIT_OPTIONS): Update. + * langhooks.h (struct lang_hooks): New prototype for init_options. + * main.c (main): Cast argv. + * opts.c (handle_option, handle_options): Update prototypes. + (decode_options): save_argc, save_argv are not global. Constify. + * opts.h (decode_options): New prototype. + * toplev.c (general_init): New protoype. + (save_argv): Make static. + (save_argc): Remove. + (print_switch_values, general_init): Constify. + (toplev_main): Save argv. + * toplev.h (toplev_main): Update prototype. + (save_argc, save_argv): Remove. + 2003-07-02 David Edelsohn * dbxout.c (pending_bincls): Guard with DBX_USE_BINCLS. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c534ae6..67417f0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2003-07-02 Neil Booth + + * misc.c (save_argc, save_argv): Make static. + (gnat_init_options): New prototype. + (gnat_init_options): Update. + 2003-07-01 Matt Kraai * gnat_ug.texi: Remove unlikely characters from @vars. diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c index e0ee975..ab618e5 100644 --- a/gcc/ada/misc.c +++ b/gcc/ada/misc.c @@ -78,12 +78,10 @@ #include "options.h" extern FILE *asm_out_file; -extern int save_argc; -extern char **save_argv; static size_t gnat_tree_size PARAMS ((enum tree_code)); static bool gnat_init PARAMS ((void)); -static int gnat_init_options PARAMS ((void)); +static unsigned int gnat_init_options (unsigned int, const char **); static int gnat_handle_option (size_t scode, const char *arg, int value); static HOST_WIDE_INT gnat_get_alias_set PARAMS ((tree)); static void gnat_print_decl PARAMS ((FILE *, tree, int)); @@ -181,6 +179,10 @@ const char *const tree_code_name[] = { }; #undef DEFTREECODE +/* Command-line argc and argv. */ +static unsigned int save_argc; +static const char **save_argv; + /* gnat standard argc argv */ extern int gnat_argc; @@ -222,7 +224,7 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) { enum opt_code code = (enum opt_code) scode; char *q; - int i; + unsigned int i; /* Ignore file names. */ if (code == N_OPTS) @@ -279,14 +281,17 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED) /* Initialize for option processing. */ -static int -gnat_init_options () +static unsigned int +gnat_init_options (unsigned int argc, const char **argv) { - /* Initialize gnat_argv with save_argv size */ - gnat_argv = (char **) xmalloc ((save_argc + 1) * sizeof (gnat_argv[0])); - gnat_argv[0] = save_argv[0]; /* name of the command */ + /* Initialize gnat_argv with save_argv size. */ + gnat_argv = (char **) xmalloc ((argc + 1) * sizeof (argv[0])); + gnat_argv[0] = argv[0]; /* name of the command */ gnat_argc = 1; + save_argc = argc; + save_argv = argv; + return CL_Ada; } diff --git a/gcc/c-common.h b/gcc/c-common.h index 0843e11..f4dc8f7 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -953,7 +953,7 @@ extern void disable_builtin_function (const char *); extern tree build_va_arg (tree, tree); -extern int c_common_init_options (void); +extern unsigned int c_common_init_options (unsigned int, const char **); extern bool c_common_post_options (const char **); extern bool c_common_init (void); extern void c_common_finish (void); diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 09c58b9..5ee53b4 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -92,8 +92,8 @@ static bool quote_chain_split; /* If -Wunused-macros. */ static bool warn_unused_macros; -/* Number of deferred options, deferred options array size. */ -static size_t deferred_count, deferred_size; +/* Number of deferred options. */ +static size_t deferred_count; /* Number of deferred options scanned for -include. */ static size_t include_cursor; @@ -191,29 +191,16 @@ missing_arg (enum opt_code code) static void defer_opt (enum opt_code code, const char *arg) { - /* FIXME: this should be in c_common_init_options, which should take - argc and argv. */ - if (!deferred_opts) - { - extern int save_argc; - deferred_size = save_argc; - deferred_opts = (struct deferred_opt *) - xmalloc (deferred_size * sizeof (struct deferred_opt)); - } - - if (deferred_count == deferred_size) - abort (); - deferred_opts[deferred_count].code = code; deferred_opts[deferred_count].arg = arg; deferred_count++; } /* Common initialization before parsing options. */ -int -c_common_init_options (void) +unsigned int +c_common_init_options (unsigned int argc, const char **argv ATTRIBUTE_UNUSED) { - static const int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX}; + static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX}; /* This is conditionalized only because that is the way the front ends used to do it. Maybe this should be unconditional? */ @@ -242,6 +229,9 @@ c_common_init_options (void) flag_exceptions = c_dialect_cxx (); warn_pointer_arith = c_dialect_cxx (); + deferred_opts = (struct deferred_opt *) + xmalloc (argc * sizeof (struct deferred_opt)); + return lang_flags[c_language]; } @@ -1406,6 +1396,7 @@ push_command_line_include (void) if (include_cursor == deferred_count) { + free (deferred_opts); /* Restore the line map from . */ cpp_change_file (parse_in, LC_RENAME, main_input_filename); /* -Wunused-macros should only warn about macros defined hereafter. */ diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 0153618..895db16 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 2 21:16:02 2003 Neil Booth + + * top.c (ffe_init_options): Update prototype. + * top.h (ffe_init_options): Update prototype. + 2003-06-27 Zack Weinberg * com.c (input_file_stack_tick): Delete redundant declaration. diff --git a/gcc/f/top.c b/gcc/f/top.c index 359dd2b..30b6eb2 100644 --- a/gcc/f/top.c +++ b/gcc/f/top.c @@ -156,8 +156,9 @@ ffe_is_digit_string_ (const char *s) } /* Get ready for options handling. */ -int -ffe_init_options () +unsigned int +ffe_init_options (unsigned int argc ATTRIBUTE_UNUSED, + const char **argv ATTRIBUTE_UNUSED) { /* Set default options for Fortran. */ flag_move_all_movables = 1; diff --git a/gcc/f/top.h b/gcc/f/top.h index 041dc16..5538ab8 100644 --- a/gcc/f/top.h +++ b/gcc/f/top.h @@ -141,7 +141,7 @@ extern bool ffe_in_4; /* Declare functions with prototypes. */ -int ffe_init_options (void); +unsigned int ffe_init_options (unsigned int, const char **); int ffe_handle_option (size_t code, const char *arg, int on); void ffe_file (ffewhereFile wf, FILE *f); void ffe_init_0 (void); diff --git a/gcc/hooks.c b/gcc/hooks.c index e183a11..7797941 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -133,6 +133,13 @@ hook_int_size_t_constcharptr_int_0 (size_t a ATTRIBUTE_UNUSED, return 0; } +unsigned int +hook_uint_uint_constcharptrptr_0 (unsigned int a ATTRIBUTE_UNUSED, + const char **b ATTRIBUTE_UNUSED) +{ + return 0; +} + void hook_void_tree (a) tree a ATTRIBUTE_UNUSED; diff --git a/gcc/hooks.h b/gcc/hooks.h index 044654a..1fdea94 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -44,6 +44,8 @@ int hook_int_void_0 (void); int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int); int hook_int_void_no_regs (void); +unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **); + bool default_can_output_mi_thunk_no_vcall PARAMS ((tree, HOST_WIDE_INT, HOST_WIDE_INT, tree)); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 2ef46cf..3cdbf8c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +2003-07-02 Neil Booth + + * lang.c (java_init_options): Update prototype. + 2003-07-01 Nathan Sidwell * decl.c (poplevel): Adjust define_label call. diff --git a/gcc/java/lang.c b/gcc/java/lang.c index b8fc498..7137bcf 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -50,7 +50,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ static bool java_init (void); static void java_finish (void); -static int java_init_options (void); +static unsigned int java_init_options (unsigned int, const char **); static bool java_post_options (const char **); static int java_handle_option (size_t scode, const char *arg, int value); @@ -664,8 +664,9 @@ void lang_init_source (int level) inhibit_error_function_printing = (level == 1); } -static int -java_init_options (void) +static unsigned int +java_init_options (unsigned int argc ATTRIBUTE_UNUSED, + const char **argv ATTRIBUTE_UNUSED) { flag_bounds_check = 1; flag_exceptions = 1; diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index e6fa38e..35597e7 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -90,8 +90,8 @@ void write_global_declarations PARAMS ((void)); #define LANG_HOOKS_FINISH lhd_do_nothing #define LANG_HOOKS_PARSE_FILE lhd_do_nothing_i #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack -#define LANG_HOOKS_INIT_OPTIONS hook_int_void_0 -#define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constharptr_int_0 +#define LANG_HOOKS_INIT_OPTIONS hook_uint_uint_constcharptrptr_0 +#define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constcharptr_int_0 #define LANG_HOOKS_POST_OPTIONS lhd_post_options #define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree diff --git a/gcc/langhooks.h b/gcc/langhooks.h index a23db42..eadff12 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -207,7 +207,7 @@ struct lang_hooks /* The first callback made to the front end, for simple initialization needed before any calls to handle_option. Return the language mask to filter the switch array with. */ - int (*init_options) PARAMS ((void)); + unsigned int (*init_options) (unsigned int argc, const char **argv); /* Handle the switch CODE, which has real type enum opt_code from options.h. If the switch takes an argument, it is passed in ARG diff --git a/gcc/main.c b/gcc/main.c index 07fa246..62ec5dd 100644 --- a/gcc/main.c +++ b/gcc/main.c @@ -34,5 +34,5 @@ main (argc, argv) int argc; char **argv; { - return toplev_main (argc, argv); + return toplev_main (argc, (const char **) argv); } diff --git a/gcc/opts.c b/gcc/opts.c index a150c3a..3f3cc13 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -131,11 +131,11 @@ static size_t find_opt (const char *, int); static int common_handle_option (size_t scode, const char *arg, int value); static void handle_param (const char *); static void set_Wextra (int); -static unsigned int handle_option (char **argv, unsigned int lang_mask); +static unsigned int handle_option (const char **argv, unsigned int lang_mask); static char *write_langs (unsigned int lang_mask); static void complain_wrong_lang (const char *, const struct cl_option *, unsigned int lang_mask); -static void handle_options (unsigned int, char **, unsigned int lang_mask); +static void handle_options (unsigned int, const char **, unsigned int); /* Perform a binary search to find which option the command-line INPUT matches. Returns its index in the option array, and N_OPTS @@ -286,7 +286,7 @@ complain_wrong_lang (const char *text, const struct cl_option *option, /* Handle the switch beginning at ARGV for the language indicated by LANG_MASK. Returns the number of switches consumed. */ static unsigned int -handle_option (char **argv, unsigned int lang_mask) +handle_option (const char **argv, unsigned int lang_mask) { size_t opt_index; const char *opt, *arg = 0; @@ -408,7 +408,7 @@ handle_option (char **argv, unsigned int lang_mask) contains has a single bit set representing the current language. */ static void -handle_options (unsigned int argc, char **argv, unsigned int lang_mask) +handle_options (unsigned int argc, const char **argv, unsigned int lang_mask) { unsigned int n, i; @@ -427,16 +427,12 @@ handle_options (unsigned int argc, char **argv, unsigned int lang_mask) /* Parse command line options and set default flag values. Do minimal options processing. */ void -decode_options (int argc, char **argv) +decode_options (unsigned int argc, const char **argv) { - int i, lang_mask; - - /* Save in case md file wants to emit args as a comment. */ - save_argc = argc; - save_argv = argv; + unsigned int i, lang_mask; /* Perform language-specific options initialization. */ - lang_mask = (*lang_hooks.init_options) (); + lang_mask = (*lang_hooks.init_options) (argc, argv); /* Scan to see what optimization level has been specified. That will determine the default value of many flags. */ @@ -450,7 +446,7 @@ decode_options (int argc, char **argv) else if (argv[i][0] == '-' && argv[i][1] == 'O') { /* Handle -Os, -O2, -O3, -O69, ... */ - char *p = &argv[i][2]; + const char *p = &argv[i][2]; if ((p[0] == 's') && (p[1] == 0)) { diff --git a/gcc/opts.h b/gcc/opts.h index 616ed71..52ab44b 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -21,7 +21,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #ifndef GCC_OPTS_H #define GCC_OPTS_H -extern void decode_options (int argc, char **argv); +extern void decode_options (unsigned int argc, const char **argv); struct cl_option { diff --git a/gcc/toplev.c b/gcc/toplev.c index da514a2..2f83d68 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -104,7 +104,7 @@ extern tree last_assemble_variable_decl; extern void reg_alloc (void); -static void general_init (char *); +static void general_init (const char *); static void do_compile (void); static void process_options (void); static void backend_init (void); @@ -172,9 +172,8 @@ static bool no_backend; const char *progname; -/* Copy of arguments to toplev_main. */ -int save_argc; -char **save_argv; +/* Copy of argument vector to toplev_main. */ +static const char **save_argv; /* Name of top-level original source file (what was input to cpp). This comes from the #-command at the beginning of the actual input. @@ -4408,7 +4407,7 @@ print_switch_values (FILE *file, int pos, int max, const char *indent, const char *sep, const char *term) { size_t j; - char **p; + const char **p; /* Fill in the -frandom-seed option, if the user didn't pass it, so that it can be printed below. This helps reproducibility. Of @@ -4537,9 +4536,9 @@ init_asm_output (const char *name) options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ static void -general_init (char *argv0) +general_init (const char *argv0) { - char *p; + const char *p; p = argv0 + strlen (argv0); while (p != argv0 && !IS_DIR_SEPARATOR (p[-1])) @@ -4975,8 +4974,10 @@ do_compile (void) It is not safe to call this function more than once. */ int -toplev_main (int argc, char **argv) +toplev_main (unsigned int argc, const char **argv) { + save_argv = argv; + /* Initialization of GCC's environment, and diagnostics. */ general_init (argv[0]); diff --git a/gcc/toplev.h b/gcc/toplev.h index 16cfacd..9cb3746 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -26,7 +26,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define skip_leading_substring(whole, part) \ (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part)) -extern int toplev_main (int, char **); +extern int toplev_main (unsigned int, const char **); extern int read_integral_parameter (const char *, const char *, const int); extern void strip_off_ending (char *, int); @@ -102,10 +102,6 @@ extern const char *asm_file_name; extern bool exit_after_options; extern bool version_flag; -/* Copy of arguments to toplev_main. */ -extern int save_argc; -extern char **save_argv; - extern int target_flags_explicit; /* See toplev.c. */ diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index f7623db..5b0e3522 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,3 +1,8 @@ +2003-07-02 Neil Booth + + * tree1.c (treelang_init_options): Update prototype. + * treelang.h (treelang_init_options): Update prototype. + 2003-07-01 Neil Booth * Make-lang.in: Update. diff --git a/gcc/treelang/tree1.c b/gcc/treelang/tree1.c index 3e85fac..54c41ee 100644 --- a/gcc/treelang/tree1.c +++ b/gcc/treelang/tree1.c @@ -92,8 +92,9 @@ static int version_done = 0; static unsigned int work_nesting_level = 0; /* Prepare to handle switches. */ -int -treelang_init_options (void) +unsigned int +treelang_init_options (unsigned int argc ATTRIBUTE_UNUSED, + const char **argv ATTRIBUTE_UNUSED) { return CL_Treelang; } diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h index 2c7aec3..7200480 100644 --- a/gcc/treelang/treetree.h +++ b/gcc/treelang/treetree.h @@ -63,7 +63,7 @@ tree tree_code_get_type (int type_num); void treelang_init_decl_processing (void); void treelang_finish (void); bool treelang_init (void); -int treelang_init_options (void); +unsigned int treelang_init_options (unsigned int, const char **); int treelang_handle_option (size_t scode, const char *arg, int value); void treelang_parse_file (int debug_flag); void push_var_level (void); -- 2.7.4