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+RFC: toplev.c hooks


To implement -MF properly, cpplib needs to do some processing after
all switches have been processed, but before cpp_start_read.  This is
because the stand-alone CPP sets up its callbacks depending on the
options specified on the command line, so cpp_start_read, which we
used before, is now too late to do this post-option processing.

I originally put this code in cpp_handle_options, but then realised
that the front ends don't use this function, but process a
switch-at-a-time with cpp_handle_option instead.

So cpplib needs to export a function to be called after all options
have been processed, but before cpp_start_read.  For integrated CPP,
this needs to take the form of a hook in toplev.c.

This patch implements that.  It seems to me that many, if not all, of
the hooks that toplev.c provides would be better done by adding them
to the lang_hooks structure below.  If nothing else, it would make a
clearer "virtualization" of toplev.c for each front end, bringing its
interface together in one place, and would probably provide more
flexibility as well.  I have things like lang_init, lang_init_options,
lang_decode_option etc. etc. in mind here.  Comments?

If others agree, I can do some follow-up patches to tidy that up.

The hooks for C, C++ and ObjC are empty; they will be filled in with
the -MF patch which I'll repost soon.  The Fortran and Java front ends
provide NULL hooks.  OK to commit this?

Bootstrapped i586 Linux; make check is looking OK.

Neil.

	* toplev.c (main): Call the front-end specific post_options
	hook if one is given.
	* toplev.h (struct_lang_hooks, lang_hooks): New.
	* c-lang.c (c_post_options, lang_hooks): Implement lang_hooks
	for the C front end.
	* cp/decl2.c (cxx_post_options, lang_hooks): Implement
	lang_hooks for the C++ front end.
	* objc/objc-act.c (objc_post_options, lang_hooks): Implement
	lang_hooks for the ObjC front end.
	* f/com.c (lang_hooks): Hooks for the Fortran front end.
	* java/lang.c (lang_hooks): Hooks for the Java front end.

Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.42
diff -u -p -r1.42 c-lang.c
--- c-lang.c	2001/01/03 20:56:19	1.42
+++ c-lang.c	2001/01/06 16:05:51
@@ -38,10 +38,19 @@ 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_post_options PARAMS ((void));
 
+/* Each front end provides its own.  */
+struct lang_hooks lang_hooks = {c_post_options};
+
+/* Post-switch processing.  */
+static void
+c_post_options ()
+{
+}
+
 /* Each of the functions defined here
    is an alternative to a function in objc-actions.c.  */
-
 int
 lang_decode_option (argc, argv)
      int argc;
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.411
diff -u -p -r1.411 toplev.c
--- toplev.c	2001/01/05 23:41:00	1.411
+++ toplev.c	2001/01/06 16:06:41
@@ -4750,6 +4750,10 @@ main (argc, argv)
 	}
     }
 
+  /* All command line options have been processed.  */
+  if (lang_hooks.post_options)
+    (*lang_hooks.post_options) ();
+
   /* Reflect any language-specific diagnostic option setting.  */
   reshape_diagnostic_buffer ();
 
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.47
diff -u -p -r1.47 toplev.h
--- toplev.h	2000/12/29 01:45:53	1.47
+++ toplev.h	2001/01/06 16:06:41
@@ -133,4 +133,14 @@ extern int sorrycount;
 
 extern const char *progname;
 
+/* Language-specific hooks.  */
+struct lang_hooks
+{
+  /* If non-NULL, called when all command line options have been processed.  */
+  void (*post_options) PARAMS ((void));
+};
+
+/* Each front end provides its own.  */
+extern struct lang_hooks lang_hooks;
+
 #endif /* __GCC_TOPLEV_H */
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.419
diff -u -p -r1.419 decl2.c
--- decl2.c	2001/01/04 23:53:54	1.419
+++ decl2.c	2001/01/06 16:07:20
@@ -59,6 +59,7 @@ typedef struct priority_info_s {
   int destructions_p;
 } *priority_info;
 
+static void cxx_post_options PARAMS ((void));
 static void mark_vtable_entries PARAMS ((tree));
 static void grok_function_init PARAMS ((tree, tree));
 static int finish_vtable_vardecl PARAMS ((tree *, void *));
@@ -542,6 +543,15 @@ static const char * const unsupported_op
   "this-is-variable",
   "strict-prototype",
 };
+
+/* Each front end provides its own.  */
+struct lang_hooks lang_hooks = {cxx_post_options};
+
+/* Post-switch processing.  */
+static void
+cxx_post_options ()
+{
+}
 
 /* Compare two option strings, pointed two by P1 and P2, for use with
    bsearch.  */
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.102
diff -u -p -r1.102 com.c
--- com.c	2000/12/18 23:58:21	1.102
+++ com.c	2001/01/06 16:08:04
@@ -14676,6 +14676,9 @@ insert_block (block)
     = chainon (current_binding_level->blocks, block);
 }
 
+/* Each front end provides its own.  */
+struct lang_hooks lang_hooks = {NULL /* post_options */};
+
 int
 lang_decode_option (argc, argv)
      int argc;
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.53
diff -u -p -r1.53 lang.c
--- lang.c	2001/01/05 07:50:24	1.53
+++ lang.c	2001/01/06 16:08:11
@@ -186,6 +186,9 @@ static int dependency_tracking = 0;
 #define DEPEND_TARGET_SET 4
 #define DEPEND_FILE_ALREADY_SET 8
 
+/* Each front end provides its own.  */
+struct lang_hooks lang_hooks = {NULL /* post_options */};
+
 /* Process an option that can accept a `no-' form.
    Return 1 if option found, 0 otherwise.  */
 static int
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.59
diff -u -p -r1.59 objc-act.c
--- objc-act.c	2001/01/03 20:56:22	1.59
+++ objc-act.c	2001/01/06 16:08:37
@@ -148,6 +148,7 @@ char *util_firstobj;
 
 static void init_objc				PARAMS ((void));
 static void finish_objc				PARAMS ((void));
+static void objc_post_options			PARAMS ((void));
 
 /* Code generation.  */
 
@@ -625,6 +626,15 @@ static int generating_instance_variables
    features and output a C header file with appropriate definitions. */
 
 static int print_struct_values = 0;
+
+/* Each front end provides its own.  */
+struct lang_hooks lang_hooks = {objc_post_options};
+
+/* Post-switch processing.  */
+static void
+objc_post_options ()
+{
+}
 
 /* Some platforms pass small structures through registers versus through
    an invisible pointer.  Determine at what size structure is the 

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