This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Small cleanup of toplev.c
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 1 Mar 2003 15:03:04 +0000
- Subject: Small cleanup of toplev.c
A small cleanup of toplev initialization. OK?
Neil.
* toplev.c (aux_base_name, filename): Make static.
(lang_dependent_init): Don't duplicate name.
(process_options): Set aux_base_name here, not...
(do_compile): ...here. Change protoype.
(toplev_main): Move some code from do_compile.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.688
diff -u -p -r1.688 toplev.c
--- toplev.c 2 Nov 2002 01:03:02 -0000 1.688
+++ toplev.c 18 Nov 2002 22:14:21 -0000
@@ -99,7 +99,7 @@ extern void reg_alloc PARAMS ((void));
static void general_init PARAMS ((char *));
static void parse_options_and_default_flags PARAMS ((int, char **));
-static void do_compile PARAMS ((void));
+static void do_compile PARAMS ((int));
static void process_options PARAMS ((void));
static void backend_init PARAMS ((void));
static int lang_dependent_init PARAMS ((const char *));
@@ -171,7 +171,7 @@ const char *dump_base_name;
/* Name to use as a base for auxiliary output files. */
-const char *aux_base_name;
+static const char *aux_base_name;
/* Format to use to print dumpfile index value */
#ifndef DUMPFILE_FORMAT
@@ -312,7 +312,7 @@ static void close_dump_file PARAMS ((enu
int rtl_dump_and_exit;
int flag_print_asm_name;
static int version_flag;
-static char *filename;
+static const char *filename;
enum graph_dump_types graph_dump_format;
/* Name for output file of assembly code, specified with -o. */
@@ -5003,6 +5003,19 @@ process_options ()
OVERRIDE_OPTIONS;
#endif
+ /* Set aux_base_name if not already set. */
+ if (aux_base_name)
+ ;
+ else if (filename)
+ {
+ char *name = xstrdup (lbasename (filename));
+
+ strip_off_ending (name, strlen (name));
+ aux_base_name = name;
+ }
+ else
+ aux_base_name = "gccaux";
+
/* Set up the align_*_log variables, defaulting them to 1 if they
were still unset. */
if (align_loops <= 0) align_loops = 1;
@@ -5218,8 +5231,6 @@ lang_dependent_init (name)
if (name == NULL)
return 0;
- /* Is this duplication necessary? */
- name = ggc_strdup (name);
main_input_filename = input_filename = name;
init_asm_output (name);
@@ -5314,31 +5325,9 @@ finalize ()
/* Initialize the compiler, and compile the input file. */
static void
-do_compile ()
+do_compile (no_backend)
+ int no_backend;
{
- /* All command line options have been parsed; allow the front end to
- perform consistency checks, etc. */
- bool no_backend = (*lang_hooks.post_options) ();
-
- /* The bulk of command line switch processing. */
- process_options ();
-
- /* If an error has already occurred, give up. */
- if (errorcount)
- return;
-
- if (aux_base_name)
- /*NOP*/;
- else if (filename)
- {
- char *name = xstrdup (lbasename (filename));
-
- aux_base_name = name;
- strip_off_ending (name, strlen (name));
- }
- else
- aux_base_name = "gccaux";
-
/* We cannot start timing until after options are processed since that
says if we run timers or not. */
init_timevar ();
@@ -5380,7 +5369,18 @@ toplev_main (argc, argv)
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
- do_compile ();
+ {
+ /* All command line options have been parsed; allow the front
+ end to perform consistency checks, etc. */
+ bool no_backend = (*lang_hooks.post_options) ();
+
+ /* The bulk of command line switch processing. */
+ process_options ();
+
+ /* Don't do any more if an error has already occurred. */
+ if (!errorcount)
+ do_compile (no_backend);
+ }
if (errorcount || sorrycount)
return (FATAL_EXIT_CODE);
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.89
diff -u -p -r1.89 toplev.h
--- toplev.h 4 Aug 2002 16:21:02 -0000 1.89
+++ toplev.h 18 Nov 2002 22:14:21 -0000
@@ -108,7 +108,6 @@ extern void check_global_declarations
extern const char *progname;
extern const char *dump_base_name;
-extern const char *aux_base_name;
extern int target_flags_explicit;