This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH to move in_fnames etc from c-opts.c to opts.c


This moves some of the support for multiple input fiels from c-opts.c to opts.c. This makes it at least potentially language-indendent. More import to me is that brings the code closer to the compiler server, as I trying to figure out how to update my compile server code to deal with Goeff's and Neil's recent check-ins. It also is a minor simplification, as it removes a useless lang hook.

Ok to check in?
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-07-30  Per Bothner  <per@bothner.com>

	* opts.c (in_fnames, num_in_fnames):  Moved here from c-opts.
	(add_input_filename):  New function.
	(handle_options):  Call add_input_filename directly instead of
	with a lang hook.
	* opts.h (in_fnames, num_in_fnames):  Moved here.
	(add_input_filename):  Declare.
	* c-decl.c:  Need to #include opts.h.
	* c-opts.c (in_fnames, num_in_fnames):  Moved to opts.c.
	(c_common_handle_filename):  Replaced by add_input_filename.
	* c-common.h (in_fnames, num_in_fnames, c_common_handle_filename):
	Remove.
	* langhooks.h (struct lang_hooks):  Remove handle_filename hook.
	* langhooks-def.h (LANG_HOOKS_HANDLE_FILENAME):  Remove macro.
	(LANG_HOOKS_INITIALIZER):  Remove use of LANG_HOOKS_HANDLE_FILENAME.
	* c-lang.c (LANG_HOOKS_HANDLE_FILENAME):  Remove macro.

Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.195
diff -u -r1.195 c-common.h
--- c-common.h	28 Jul 2003 20:03:25 -0000	1.195
+++ c-common.h	29 Jul 2003 21:12:58 -0000
@@ -853,11 +853,6 @@
 
 extern int skip_evaluation;
 
-/* The count of input filenames.  Only really valid for comparisons
-   against 1.  */
-
-extern unsigned num_in_fnames;
-
 /* C types are partitioned into three subsets: object, function, and
    incomplete types.  */
 #define C_TYPE_OBJECT_P(type) \
@@ -909,7 +904,6 @@
 extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
 extern void c_common_insert_default_attributes (tree);
 extern int c_common_handle_option (size_t code, const char *arg, int value);
-extern void c_common_handle_filename (const char *filename);
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.423
diff -u -r1.423 c-decl.c
--- c-decl.c	29 Jul 2003 04:14:48 -0000	1.423
+++ c-decl.c	29 Jul 2003 21:12:58 -0000
@@ -45,6 +45,7 @@
 #include "cpplib.h"
 #include "target.h"
 #include "debug.h"
+#include "opts.h"
 #include "timevar.h"
 #include "c-common.h"
 #include "c-pragma.h"
Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.110
diff -u -r1.110 c-lang.c
--- c-lang.c	17 Jul 2003 21:52:49 -0000	1.110
+++ c-lang.c	29 Jul 2003 21:12:58 -0000
@@ -45,8 +45,6 @@
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
-#undef LANG_HOOKS_HANDLE_FILENAME
-#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
 #undef LANG_HOOKS_MISSING_ARGUMENT
 #define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
 #undef LANG_HOOKS_POST_OPTIONS
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.80
diff -u -r1.80 c-opts.c
--- c-opts.c	28 Jul 2003 20:03:25 -0000	1.80
+++ c-opts.c	29 Jul 2003 21:12:59 -0000
@@ -52,8 +52,6 @@
 static cpp_options *cpp_opts;
 
 /* Input filename.  */
-static const char **in_fnames;
-unsigned num_in_fnames;
 static const char *this_input_filename;
 
 /* Filename and stream for preprocessed output.  */
@@ -1035,15 +1033,6 @@
   return result;
 }
 
-/* Handle FILENAME from the command line.  */
-void
-c_common_handle_filename (const char *filename)
-{
-  num_in_fnames++;
-  in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
-  in_fnames[num_in_fnames - 1] = filename;
-}
-
 /* Post-switch processing.  */
 bool
 c_common_post_options (const char **pfilename)
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.57
diff -u -r1.57 langhooks-def.h
--- langhooks-def.h	11 Jul 2003 08:33:15 -0000	1.57
+++ langhooks-def.h	29 Jul 2003 21:12:59 -0000
@@ -88,7 +88,6 @@
 #define LANG_HOOKS_CLEAR_BINDING_STACK	lhd_clear_binding_stack
 #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_HANDLE_FILENAME	hook_void_constcharptr
 #define LANG_HOOKS_MISSING_ARGUMENT	hook_bool_constcharptr_size_t_false
 #define LANG_HOOKS_POST_OPTIONS		lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET	lhd_get_alias_set
@@ -247,7 +246,6 @@
   LANG_HOOKS_TREE_SIZE, \
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_HANDLE_OPTION, \
-  LANG_HOOKS_HANDLE_FILENAME, \
   LANG_HOOKS_MISSING_ARGUMENT, \
   LANG_HOOKS_POST_OPTIONS, \
   LANG_HOOKS_INIT, \
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.66
diff -u -r1.66 langhooks.h
--- langhooks.h	10 Jul 2003 11:38:17 -0000	1.66
+++ langhooks.h	29 Jul 2003 21:12:59 -0000
@@ -213,9 +213,6 @@
      valid and should not be treated as language-independent too.  */
   int (*handle_option) (size_t code, const char *arg, int value);
 
-  /* Handle a filename on the command line.  */
-  void (*handle_filename) (const char *filename);
-
   /* Return false to use the default complaint about a missing
      argument, otherwise output a complaint and return true.  */
   bool (*missing_argument) (const char *opt, size_t code);
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.32
diff -u -r1.32 opts.c
--- opts.c	25 Jul 2003 09:52:25 -0000	1.32
+++ opts.c	29 Jul 2003 21:12:59 -0000
@@ -134,6 +134,10 @@
 /* What to print when a switch has no documentation.  */
 static const char undocumented_msg[] = N_("This switch lacks documentation");
 
+/* Input file names. */
+const char **in_fnames;
+unsigned num_in_fnames;
+
 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 *);
@@ -422,7 +426,7 @@
       if (opt[0] != '-' || opt[1] == '\0')
 	{
 	  main_input_filename = opt;
-	  (*lang_hooks.handle_filename) (opt);
+	  add_input_filename (opt);
 	  n = 1;
 	  continue;
 	}
@@ -435,6 +439,15 @@
 	  error ("unrecognized command line option \"%s\"", opt);
 	}
     }
+}
+
+/* Handle FILENAME from the command line.  */
+void
+add_input_filename (const char *filename)
+{
+  num_in_fnames++;
+  in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
+  in_fnames[num_in_fnames - 1] = filename;
 }
 
 /* Parse command line options and set default flag values.  Do minimal
Index: opts.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.h,v
retrieving revision 1.11
diff -u -r1.11 opts.h
--- opts.h	17 Jul 2003 05:33:09 -0000	1.11
+++ opts.h	29 Jul 2003 21:12:59 -0000
@@ -22,6 +22,7 @@
 #define GCC_OPTS_H
 
 extern void decode_options (unsigned int argc, const char **argv);
+extern void add_input_filename (const char *filename);
 
 struct cl_option
 {
@@ -43,5 +44,13 @@
 #define CL_UINTEGER		(1 << 28) /* Argument is an integer >=0.  */
 #define CL_COMMON		(1 << 29) /* Language-independent.  */
 #define CL_UNDOCUMENTED		(1 << 30) /* Do not output with --help.  */
+
+/* Input file names. */
+
+extern const char **in_fnames;
+
+/* The count of input filenames. */
+
+extern unsigned num_in_fnames;
 
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]