This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Move more switches out of toplev.c to opts.c
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 15 Jun 2003 09:24:47 +0100
- Subject: Move more switches out of toplev.c to opts.c
Bootstrapped and regtested C, ObjC, C++, F77, Java and Treelang on
x86 NetBSD.
Neil.
* c-pch.c (asm_file_name): Remove.
* common.opt: Add more switches.
* flags.h (g_switch_set): Boolify.
* opts.c (g_switch_value, g_switch_set, exit_after_options,
version_flag): Move from toplev.c.
(common_handle_option): Handle more switches from toplev.c.
* toplev.c (display_help, display_target_options, decode_d_option,
print_version): Make non-static, remove prototypes.
(aux_base_name, asm_file_name, aux_info_file_name): Constify.
(version_flag, g_switch_value, g_switch_set, exit_after_options):
Remove.
(independent_decode_option): Move some handlers to opts.c.
* toplev.h (aux_info_file_name, aux_base_name, asm_file_name,
exit_after_options, version_flag, display_help, display_target_options,
print_version, decode_d_option): New.
java:
* lang.c (version_flag): Rename to v_flag to avoid clash w/ toplev.h.
Index: c-pch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pch.c,v
retrieving revision 1.9
diff -u -p -b -r1.9 c-pch.c
--- c-pch.c 13 May 2003 18:06:44 -0000 1.9
+++ c-pch.c 15 Jun 2003 08:16:07 -0000
@@ -46,7 +46,6 @@ struct c_pch_header
static FILE *pch_outfile;
-extern char *asm_file_name;
static long asm_file_startpos;
static const char * get_ident PARAMS((void));
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.1
diff -u -p -b -r1.1 common.opt
--- common.opt 14 Jun 2003 12:26:28 -0000 1.1
+++ common.opt 15 Jun 2003 08:16:07 -0000
@@ -41,7 +41,55 @@
; Please try to keep this file in ASCII collating order.
+-help
+Common
+
+-target-help
+Common
+
+-version
+Common
+
+G
+Common Joined Separate
+
+aux-info
+Common Separate
+
+aux-info=
+Common Joined
+
+auxbase
+Common Separate
+
+auxbase-strip
+Common Separate
+
+d
+Common Joined
+
+dumpbase
+Common Separate
+
+o
+Common Joined Separate
+
+p
+Common
+
+pedantic
+Common
+
+pedantic-errors
+Common
+
quiet
+Common
+
+version
+Common
+
+w
Common
; This comment is to ensure we retain the blank line above.
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.110
diff -u -p -b -r1.110 flags.h
--- flags.h 3 Jun 2003 09:06:46 -0000 1.110
+++ flags.h 15 Jun 2003 08:16:07 -0000
@@ -600,7 +600,7 @@ extern int flag_wrapv;
/* Value of the -G xx switch, and whether it was passed or not. */
extern unsigned HOST_WIDE_INT g_switch_value;
-extern int g_switch_set;
+extern bool g_switch_set;
/* Values of the -falign-* flags: how much to align labels in code.
0 means `use default', 1 means `don't align'.
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.5
diff -u -p -b -r1.5 opts.c
--- opts.c 14 Jun 2003 12:26:31 -0000 1.5
+++ opts.c 15 Jun 2003 08:16:08 -0000
@@ -30,6 +30,16 @@ Software Foundation, 59 Temple Place - S
#include "flags.h"
#include "toplev.h"
+/* Value of the -G xx switch, and whether it was passed or not. */
+unsigned HOST_WIDE_INT g_switch_value;
+bool g_switch_set;
+
+/* True if we should exit after parsing options. */
+bool exit_after_options;
+
+/* If -version. */
+bool version_flag;
+
static size_t find_opt (const char *, int);
static int common_handle_option (size_t scode, const char *arg, int value);
@@ -236,9 +246,82 @@ common_handle_option (size_t scode, cons
default:
abort ();
+ case OPT__help:
+ display_help ();
+ exit_after_options = true;
+ break;
+
+ case OPT__target_help:
+ display_target_options ();
+ exit_after_options = true;
+ break;
+
+ case OPT__version:
+ print_version (stderr, "");
+ exit_after_options = true;
+ break;
+
+ case OPT_G:
+ g_switch_value = read_integral_parameter (arg, 0, -1);
+ if (g_switch_value == (unsigned HOST_WIDE_INT) -1)
+ return 0;
+ g_switch_set = true;
+ break;
+
+ case OPT_aux_info:
+ case OPT_aux_info_:
+ aux_info_file_name = arg;
+ flag_gen_aux_info = 1;
+ break;
+
+ case OPT_auxbase:
+ aux_base_name = arg;
+ break;
+
+ case OPT_auxbase_strip:
+ {
+ char *tmp = xstrdup (arg);
+ strip_off_ending (tmp, strlen (tmp));
+ if (tmp[0])
+ aux_base_name = tmp;
+ }
+ break;
+
+ case OPT_d:
+ decode_d_option (arg);
+ break;
+
+ case OPT_dumpbase:
+ dump_base_name = arg;
+ break;
+
+ case OPT_o:
+ asm_file_name = arg;
+ break;
+
+ case OPT_p:
+ profile_flag = 1;
+ break;
+
+ case OPT_pedantic:
+ pedantic = 1;
+ break;
+
+ case OPT_pedantic_errors:
+ flag_pedantic_errors = pedantic = 1;
+ break;
+
case OPT_quiet:
quiet_flag = 1;
break;
+
+ case OPT_version:
+ version_flag = 1;
+ break;
+
+ case OPT_w:
+ inhibit_warnings = 1;
+ break;
}
return 1;
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.770
diff -u -p -b -r1.770 toplev.c
--- toplev.c 14 Jun 2003 12:26:31 -0000 1.770
+++ toplev.c 15 Jun 2003 08:16:09 -0000
@@ -117,17 +117,14 @@ static void set_target_switch (const cha
static void crash_signal (int) ATTRIBUTE_NORETURN;
static void setup_core_dumping (void);
static void compile_file (void);
-static void display_help (void);
-static void display_target_options (void);
-static void decode_d_option (const char *);
+void decode_d_option (const char *);
static int decode_f_option (const char *);
static int decode_W_option (const char *);
static int decode_g_option (const char *);
static unsigned int independent_decode_option (int, char **);
static void set_Wextra (int);
-static void print_version (FILE *, const char *);
static int print_single_switch (FILE *, int, int, const char *,
const char *, const char *,
const char *, const char *);
@@ -214,7 +211,7 @@ const char *dump_base_name;
/* Name to use as a base for auxiliary output files. */
-static const char *aux_base_name;
+const char *aux_base_name;
/* Format to use to print dumpfile index value */
#ifndef DUMPFILE_FORMAT
@@ -358,16 +355,11 @@ static void close_dump_file (enum dump_f
int rtl_dump_and_exit;
int flag_print_asm_name;
-static int version_flag;
enum graph_dump_types graph_dump_format;
/* Name for output file of assembly code, specified with -o. */
-char *asm_file_name;
-
-/* Value of the -G xx switch, and whether it was passed or not. */
-unsigned HOST_WIDE_INT g_switch_value;
-int g_switch_set;
+const char *asm_file_name;
/* Type(s) of debugging information we are producing (if any).
See flags.h for the definitions of the different possible
@@ -400,9 +392,6 @@ int optimize = 0;
int optimize_size = 0;
-/* Nonzero if we should exit after parsing options. */
-static int exit_after_options = 0;
-
/* The FUNCTION_DECL for the function currently being compiled,
or 0 if between functions. */
tree current_function_decl;
@@ -743,7 +732,7 @@ int flag_gen_aux_info = 0;
/* Specified name of aux-info file. */
-static char *aux_info_file_name;
+const char *aux_info_file_name;
/* Nonzero means make the text shared if supported. */
@@ -4011,7 +4000,7 @@ rest_of_compilation (tree decl)
}
/* Display help for generic options. */
-static void
+void
display_help (void)
{
int undoc;
@@ -4145,7 +4134,7 @@ display_help (void)
}
/* Display help for target options. */
-static void
+void
display_target_options (void)
{
int undoc, i;
@@ -4154,6 +4143,7 @@ display_target_options (void)
/* Avoid double printing for --help --target-help. */
if (displayed)
return;
+
displayed = true;
if (ARRAY_SIZE (target_switches) > 1
@@ -4217,7 +4207,7 @@ display_target_options (void)
/* Parse a -d... command line switch. */
-static void
+void
decode_d_option (const char *arg)
{
int i, c, matched;
@@ -4597,27 +4587,6 @@ independent_decode_option (int argc, cha
arg++;
- if (!strcmp (arg, "-help"))
- {
- display_help ();
- exit_after_options = 1;
- return 1;
- }
-
- if (!strcmp (arg, "-target-help"))
- {
- display_target_options ();
- exit_after_options = 1;
- return 1;
- }
-
- if (!strcmp (arg, "-version"))
- {
- print_version (stderr, "");
- exit_after_options = 1;
- return 1;
- }
-
/* Handle '--param <name>=<value>'. */
if (strcmp (arg, "-param") == 0)
{
@@ -4671,46 +4640,6 @@ independent_decode_option (int argc, cha
case 'g':
return decode_g_option (arg + 1);
- case 'd':
- if (!strcmp (arg, "dumpbase"))
- {
- if (argc == 1)
- return 0;
-
- if (argv[1][0])
- dump_base_name = argv[1];
-
- return 2;
- }
- else
- decode_d_option (arg + 1);
- break;
-
- case 'p':
- if (!strcmp (arg, "pedantic"))
- pedantic = 1;
- else if (!strcmp (arg, "pedantic-errors"))
- flag_pedantic_errors = pedantic = 1;
- else if (arg[1] == 0)
- profile_flag = 1;
- else
- return 0;
- break;
-
- case 'v':
- if (!strcmp (arg, "version"))
- version_flag = 1;
- else
- return 0;
- break;
-
- case 'w':
- if (arg[1] == 0)
- inhibit_warnings = 1;
- else
- return 0;
- break;
-
case 'W':
/* For backward compatibility, -W is the same as -Wextra. */
if (arg[1] == 0)
@@ -4718,95 +4647,6 @@ independent_decode_option (int argc, cha
else
return decode_W_option (arg + 1);
break;
-
- case 'a':
- if (!strncmp (arg, "aux-info", 8))
- {
- if (arg[8] == '\0')
- {
- if (argc == 1)
- return 0;
-
- aux_info_file_name = argv[1];
- flag_gen_aux_info = 1;
- return 2;
- }
- else if (arg[8] == '=')
- {
- aux_info_file_name = arg + 9;
- flag_gen_aux_info = 1;
- }
- else
- return 0;
- }
- else if (!strcmp (arg, "auxbase"))
- {
- if (argc == 1)
- return 0;
-
- if (argv[1][0])
- aux_base_name = argv[1];
-
- return 2;
- }
- else if (!strcmp (arg, "auxbase-strip"))
- {
- if (argc == 1)
- return 0;
-
- if (argv[1][0])
- {
- strip_off_ending (argv[1], strlen (argv[1]));
- if (argv[1][0])
- aux_base_name = argv[1];
- }
-
- return 2;
- }
- else
- return 0;
- break;
-
- case 'o':
- if (arg[1] == 0)
- {
- if (argc == 1)
- return 0;
-
- asm_file_name = argv[1];
- return 2;
- }
- return 0;
-
- case 'G':
- {
- int g_switch_val;
- int return_val;
-
- if (arg[1] == 0)
- {
- if (argc == 1)
- return 0;
-
- g_switch_val = read_integral_parameter (argv[1], 0, -1);
- return_val = 2;
- }
- else
- {
- g_switch_val = read_integral_parameter (arg + 1, 0, -1);
- return_val = 1;
- }
-
- if (g_switch_val == -1)
- return_val = 0;
- else
- {
- g_switch_set = TRUE;
- g_switch_value = g_switch_val;
- }
-
- return return_val;
- }
}
return 1;
@@ -4870,7 +4710,7 @@ set_target_switch (const char *name)
Each line begins with INDENT (for the case where FILE is the
assembler output file). */
-static void
+void
print_version (FILE *file, const char *indent)
{
#ifndef __VERSION__
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.95
diff -u -p -b -r1.95 toplev.h
--- toplev.h 1 Jun 2003 16:04:54 -0000 1.95
+++ toplev.h 15 Jun 2003 08:16:09 -0000
@@ -97,9 +97,18 @@ extern void check_global_declarations
extern const char *progname;
extern const char *dump_base_name;
+extern const char *aux_base_name;
+extern const char *aux_info_file_name;
+extern const char *asm_file_name;
+extern bool exit_after_options;
+extern bool version_flag;
extern int target_flags_explicit;
+extern void display_help (void);
+extern void display_target_options (void);
+extern void print_version (FILE *, const char *);
+
/* The hashtable, so that the C front ends can pass it to cpplib. */
extern struct ht *ident_hash;
@@ -107,6 +116,9 @@ extern struct ht *ident_hash;
implied by -ffast-math and -fno-fast-math. */
extern void set_fast_math_flags (int);
+
+/* Handle -d switch. */
+extern void decode_d_option (const char *);
/* Return true iff flags are set as if -ffast-math. */
extern bool fast_math_flags_set_p (void);
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.132
diff -u -p -b -r1.132 lang.c
--- java/lang.c 14 Jun 2003 22:25:50 -0000 1.132
+++ java/lang.c 15 Jun 2003 08:16:10 -0000
@@ -181,7 +181,7 @@ int flag_indirect_dispatch = 0;
int flag_store_check = 1;
/* When nonzero, print extra version information. */
-static int version_flag = 0;
+static int v_flag = 0;
/* Set nonzero if the user specified -finline-functions on the command
line. */
@@ -448,7 +448,7 @@ java_handle_option (size_t scode, const
break;
case OPT_version:
- version_flag = 1;
+ v_flag = 1;
break;
}
@@ -476,7 +476,7 @@ java_init (void)
&& force_align_functions_log < 1)
force_align_functions_log = 1;
- jcf_path_seal (version_flag);
+ jcf_path_seal (v_flag);
java_init_decl_processing ();