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]

[RFA] Language hooks 2


More language hooks, for lang_init_options and lang_decode_option.

Bootstrapped && made check.  OK to commit?

Neil.

	* c-lang.c (lang_hooks): Update.
	(lang_decode_option): Remove.
	(lang_init_options): Rename c_init_options.
	* toplev.c (main): Use lang_hooks for lang_init_options
	and lang_decode_option.
	* toplev.h (lang_hooks): Add 2 new hooks.
	* tree.h: Remove lang_init_options and lang_decode_option.
	* cp/cp-tree.h (lang_decode_option): Rename cxx_decode_option.
	* cp/decl2.c: Similarly.
	* cp/lex.c (lang_init_options): Rename cxx_init_options.
	(lang_hooks): Update.
	* f/com.c (f_init, f_finish): Rename ffe_init, ffe_finish
	for consistency.
	(lang_init_options): Rename ffe_init_options.
	(lang_hooks): Update.
	(lang_decode_option): Remove.
	* java/lang.c (lang_init_options): Rename java_init_options.
	(lang_decode_option): Rename java_decode_option.
	(lang_hooks): Update.
	* objc/objc-act.c (lang_init_options): Rename objc_init_options.
	(lang_decode_option): Rename objc_decode_option.
	(lang_hooks): Update.

Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.45
diff -u -p -r1.45 c-lang.c
--- c-lang.c	2001/01/09 10:53:59	1.45
+++ c-lang.c	2001/01/09 23:03:34
@@ -39,11 +39,14 @@ Boston, MA 02111-1307, USA.  */
 static int c_tree_printer PARAMS ((output_buffer *));
 static int c_missing_noreturn_ok_p PARAMS ((tree));
 static void c_init PARAMS ((void));
+static void c_init_options PARAMS ((void));
 static void c_post_options PARAMS ((void));
 
 /* Each front end provides its own.  */
 struct lang_hooks lang_hooks = {c_init,
 				NULL, /* c_finish */
+				c_init_options,
+				c_decode_option,
 				c_post_options};
 
 /* Post-switch processing.  */
@@ -53,18 +56,8 @@ c_post_options ()
   cpp_post_options (parse_in);
 }
 
-/* Each of the functions defined here
-   is an alternative to a function in objc-actions.c.  */
-int
-lang_decode_option (argc, argv)
-     int argc;
-     char **argv;
-{
-  return c_decode_option (argc, argv);
-}
-
-void
-lang_init_options ()
+static void
+c_init_options ()
 {
   parse_in = cpp_create_reader (CLK_GNUC89);
 
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.414
diff -u -p -r1.414 toplev.c
--- toplev.c	2001/01/09 10:53:59	1.414
+++ toplev.c	2001/01/09 23:04:38
@@ -4590,7 +4590,8 @@ main (argc, argv)
   initialize_diagnostics ();
 
   /* Perform language-specific options intialization.  */
-  lang_init_options ();
+  if (lang_hooks.init_options)
+    (*lang_hooks.init_options) ();
 
   /* Scan to see what optimization level has been specified.  That will
      determine the default value of many flags.  */
@@ -4700,7 +4701,7 @@ main (argc, argv)
       unsigned int indep_processed;
 
       /* Give the language a chance to decode the option for itself.  */
-      lang_processed = lang_decode_option (argc - i, argv + i);
+      lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
 
       /* Now see if the option also has a language independent meaning.
 	 Some options are both language specific and language independent,
@@ -4770,7 +4771,7 @@ main (argc, argv)
       flag_no_inline = 1;
       warn_inline = 0;
 
-      /* The c_decode_option and lang_decode_option functions set
+      /* The c_decode_option function and decode_option hook set
 	 this to `2' if -Wall is used, so we can avoid giving out
 	 lots of errors for people who don't realize what -Wall does.  */
       if (warn_uninitialized == 1)
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.50
diff -u -p -r1.50 toplev.h
--- toplev.h	2001/01/09 10:54:00	1.50
+++ toplev.h	2001/01/09 23:04:38
@@ -142,6 +142,16 @@ struct lang_hooks
   /* Called last, as a finalizer.  */
   void (*finish) PARAMS ((void));
 
+  /* Called to initialize options, before any calls to decode_option.  */
+  void (*init_options) PARAMS ((void));
+
+  /* Function called with an option vector as argument, to decode a
+     single option (typically starting with -f or -W or +).  It should
+     return the number of command-line arguments it uses if it handles
+     the option, or 0 and not complain if it does not recognise the
+     option.  This hook cannot be NULL.  */
+  int (*decode_option) PARAMS ((int, char **));
+
   /* Called when all command line options have been processed.  */
   void (*post_options) PARAMS ((void));
 };
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.216
diff -u -p -r1.216 tree.h
--- tree.h	2001/01/09 10:54:00	1.216
+++ tree.h	2001/01/09 23:04:46
@@ -2563,9 +2563,6 @@ extern tree fold_builtin		PARAMS ((tree)
 
 /* The language front-end must define these functions.  */
 
-/* Function of no arguments for initializing options.  */
-extern void lang_init_options			PARAMS ((void));
-
 /* Function of no arguments for initializing lexical scanning.  */
 extern void init_lex				PARAMS ((void));
 /* Function of no arguments for initializing the symbol table.  */
@@ -2583,11 +2580,6 @@ extern void copy_lang_decl			PARAMS ((tr
 
 /* Function called with no arguments to parse and compile the input.  */
 extern int yyparse				PARAMS ((void));
-/* Function called with option as argument
-   to decode options starting with -f or -W or +.
-   It should return nonzero if it handles the option.  */
-extern int lang_decode_option			PARAMS ((int, char **));
-
 /* Functions for processing symbol declarations.  */
 /* Function to enter a new lexical scope.
    Takes one argument: always zero when called from outside the front end.  */
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.558
diff -u -p -r1.558 cp-tree.h
--- cp-tree.h	2001/01/09 10:54:00	1.558
+++ cp-tree.h	2001/01/09 23:05:10
@@ -3913,7 +3913,7 @@ extern tmpl_spec_kind current_tmpl_spec_
 /* in decl2.c */
 extern void init_decl2				PARAMS ((void));
 extern int check_java_method			PARAMS ((tree));
-extern int lang_decode_option			PARAMS ((int, char **));
+extern int cxx_decode_option			PARAMS ((int, char **));
 extern int grok_method_quals			PARAMS ((tree, tree, tree));
 extern void warn_if_unknown_interface		PARAMS ((tree));
 extern void grok_x_components			PARAMS ((tree));
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.424
diff -u -p -r1.424 decl2.c
--- decl2.c	2001/01/09 10:54:01	1.424
+++ decl2.c	2001/01/09 23:05:25
@@ -560,7 +560,7 @@ compare_options (p1, p2)
    recognise the option.  */
 
 int   
-lang_decode_option (argc, argv)
+cxx_decode_option (argc, argv)
      int argc;
      char **argv;
 {
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.232
diff -u -p -r1.232 lex.c
--- lex.c	2001/01/09 10:54:01	1.232
+++ lex.c	2001/01/09 23:05:36
@@ -63,6 +63,7 @@ static void handle_pragma_interface PARA
 static void handle_pragma_implementation PARAMS ((cpp_reader *));
 static void cxx_init PARAMS ((void));
 static void cxx_finish PARAMS ((void));
+static void cxx_init_options PARAMS ((void));
 static void cxx_post_options PARAMS ((void));
 
 #ifdef GATHER_STATISTICS
@@ -246,6 +247,8 @@ static const char *cplus_tree_code_name[
 /* Each front end provides its own hooks, for toplev.c.  */
 struct lang_hooks lang_hooks = {cxx_init,
 				cxx_finish,
+				cxx_init_options,
+				cxx_decode_option,
 				cxx_post_options};
 
 /* Post-switch processing.  */
@@ -255,8 +258,8 @@ cxx_post_options ()
   cpp_post_options (parse_in);
 }
 
-void
-lang_init_options ()
+static void
+cxx_init_options ()
 {
   parse_in = cpp_create_reader (CLK_GNUCXX);
 
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.104
diff -u -p -r1.104 com.c
--- com.c	2001/01/09 10:54:01	1.104
+++ com.c	2001/01/09 23:06:14
@@ -14677,21 +14677,16 @@ insert_block (block)
 }
 
 /* Each front end provides its own.  */
-static void f_init PARAMS ((void));
-static void f_finish PARAMS ((void));
-
-struct lang_hooks lang_hooks = {f_init,
-				f_finish,
+static void ffe_init PARAMS ((void));
+static void ffe_finish PARAMS ((void));
+static void ffe_init_options PARAMS ((void));
+
+struct lang_hooks lang_hooks = {ffe_init,
+				ffe_finish,
+				ffe_init_options,
+				ffe_decode_option,
 				NULL /* post_options */};
 
-int
-lang_decode_option (argc, argv)
-     int argc;
-     char **argv;
-{
-  return ffe_decode_option (argc, argv);
-}
-
 /* used by print-tree.c */
 
 void
@@ -14703,7 +14698,7 @@ lang_print_xnode (file, node, indent)
 }
 
 static void
-f_finish ()
+ffe_finish ()
 {
   ffe_terminate_0 ();
 
@@ -14732,8 +14727,8 @@ lang_get_alias_set (t)
   return 0;
 }
 
-void
-lang_init_options ()
+static void
+ffe_init_options ()
 {
   /* Set default options for Fortran.  */
   flag_move_all_movables = 1;
@@ -14744,7 +14739,7 @@ lang_init_options ()
 }
 
 static void
-f_init ()
+ffe_init ()
 {
   /* If the file is output from cpp, it should contain a first line
      `# 1 "real-filename"', and the current design of gcc (toplev.c
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.55
diff -u -p -r1.55 lang.c
--- lang.c	2001/01/09 10:54:01	1.55
+++ lang.c	2001/01/09 23:06:19
@@ -46,6 +46,8 @@ struct string_option
 };
 
 static void java_init PARAMS ((void));
+static void java_init_options PARAMS ((void));
+static int java_decode_option PARAMS ((int, char **));
 static void put_decl_string PARAMS ((const char *, int));
 static void put_decl_node PARAMS ((tree));
 static void java_dummy_print PARAMS ((const char *));
@@ -190,6 +192,8 @@ static int dependency_tracking = 0;
 /* Each front end provides its own.  */
 struct lang_hooks lang_hooks = {java_init,
 				NULL, /* java_finish */
+				java_init_options,
+				java_decode_option,
 				NULL /* post_options */};
 
 /* Process an option that can accept a `no-' form.
@@ -224,8 +228,8 @@ process_option_with_no (p, table, table_
  * process java-specific compiler command-line options
  * return 0, but do not complain if the option is not recognised.
  */
-int
-lang_decode_option (argc, argv)
+static int
+java_decode_option (argc, argv)
      int argc __attribute__ ((__unused__));
      char **argv;
 {
@@ -678,8 +682,8 @@ void lang_init_source (level)
     print_error_function = lang_print_error;
 }
 
-void
-lang_init_options ()
+static void
+java_init_options ()
 {
   flag_new_exceptions = 1;
   flag_bounds_check = 1;
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.62
diff -u -p -r1.62 objc-act.c
--- objc-act.c	2001/01/09 10:54:01	1.62
+++ objc-act.c	2001/01/09 23:06:36
@@ -148,8 +148,10 @@ char *util_firstobj;
 
 static void init_objc				PARAMS ((void));
 static void finish_objc				PARAMS ((void));
-static void objc_post_options			PARAMS ((void));
 static void objc_init				PARAMS ((void));
+static void objc_init_options			PARAMS ((void));
+static int objc_decode_option			PARAMS ((int, char **));
+static void objc_post_options			PARAMS ((void));
 
 /* Code generation.  */
 
@@ -631,6 +633,8 @@ static int print_struct_values = 0;
 /* Each front end provides its own.  */
 struct lang_hooks lang_hooks = {objc_init,
 				NULL, /* objc_finish */
+				objc_init_options,
+				objc_decode_option,
 				objc_post_options};
 
 /* Post-switch processing.  */
@@ -703,8 +707,8 @@ generate_struct_by_value_array ()
   exit (0);
 }
 
-void
-lang_init_options ()
+static void
+objc_init_options ()
 {
   parse_in = cpp_create_reader (CLK_OBJC);
   c_language = clk_objective_c;
@@ -774,8 +778,8 @@ lang_identify ()
   return "objc";
 }
 
-int
-lang_decode_option (argc, argv)
+static int
+objc_decode_option (argc, argv)
      int argc;
      char **argv;
 {

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