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] Kill clear_binding_stack langhook


This hook is called in only one place, and just after *another* langhook. So the two can effectively be merged.

For Java, in addition, the langhook is useless after the source-level parser was removed. Therefore I changed it to an assertion.

Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?

Paolo
2008-03-11  Paolo Bonzini  <bonzini@gnu.org>

	* langhooks-def.h (LANG_HOOKS_CLEAR_BINDING_STACK): Delete.
	* langhooks.h (struct lang_hooks): Delete clear_binding_stack member.
	* toplev.c (compile_file): Don't call it.

2008-03-11  Paolo Bonzini  <bonzini@gnu.org>

	* jcf-parse.c (java_parse_file): Assert binding levels are
	left in order.
	* lang.c (LANG_HOOKS_CLEAR_BINDING_STACK, java_clear_binding_stack):
	Delete.

2008-03-11  Paolo Bonzini  <bonzini@gnu.org>

	* f95-lang.c (LANG_HOOKS_CLEAR_BINDING_STACK): Delete.
	(gfc_be_parse_file): Call gfc_clear_binding_stack from here.

Index: java/jcf-parse.c
===================================================================
--- java/jcf-parse.c	(revision 133001)
+++ java/jcf-parse.c	(working copy)
@@ -1702,6 +1702,7 @@ java_emit_static_constructor (void)
     cgraph_build_static_cdtor ('I', body, DEFAULT_INIT_PRIORITY);
 }
 
+
 void
 java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 {
@@ -1952,6 +1953,7 @@ java_parse_file (int set_yydebug ATTRIBU
  finish:
   /* Arrange for any necessary initialization to happen.  */
   java_emit_static_constructor ();
+  gcc_assert (global_bindings_p ());
 
   /* Only finalize the compilation unit after we've told cgraph which
      functions have their addresses stored.  */
Index: java/lang.c
===================================================================
--- java/lang.c	(revision 133001)
+++ java/lang.c	(working copy)
@@ -62,7 +62,6 @@ static bool java_dump_tree (void *, tree
 static void dump_compound_expr (dump_info_p, tree);
 static bool java_decl_ok_for_sibcall (const_tree);
 static tree java_get_callee_fndecl (const_tree);
-static void java_clear_binding_stack (void);
 
 static enum classify_record java_classify_record (tree type);
 
@@ -197,9 +196,6 @@ struct language_function GTY(())
 #undef LANG_HOOKS_GET_CALLEE_FNDECL
 #define LANG_HOOKS_GET_CALLEE_FNDECL java_get_callee_fndecl
 
-#undef LANG_HOOKS_CLEAR_BINDING_STACK
-#define LANG_HOOKS_CLEAR_BINDING_STACK java_clear_binding_stack
-
 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME java_mangle_decl
 
@@ -949,14 +945,6 @@ java_get_callee_fndecl (const_tree call_
 }
 
 
-/* Clear the binding stack.  */
-static void
-java_clear_binding_stack (void)
-{
-  while (!global_bindings_p ())
-    poplevel (0, 0, 0);
-}
-
 static enum classify_record
 java_classify_record (tree type)
 {
Index: toplev.c
===================================================================
--- toplev.c	(revision 133001)
+++ toplev.c	(working copy)
@@ -958,10 +958,6 @@ compile_file (void)
      rest_of_compilation for each function).  */
   lang_hooks.parse_file (set_yydebug);
 
-  /* In case there were missing block closers,
-     get us back to the global binding level.  */
-  lang_hooks.clear_binding_stack ();
-
   /* Compilation is now finished except for writing
      what's left of the symbol table output.  */
   timevar_pop (TV_PARSE);
Index: fortran/f95-lang.c
===================================================================
--- fortran/f95-lang.c	(revision 133001)
+++ fortran/f95-lang.c	(working copy)
@@ -111,7 +111,6 @@ static alias_set_type gfc_get_alias_set 
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #undef LANG_HOOKS_TYPE_FOR_SIZE
-#undef LANG_HOOKS_CLEAR_BINDING_STACK
 #undef LANG_HOOKS_GET_ALIAS_SET
 #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
 #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
@@ -134,7 +133,6 @@ static alias_set_type gfc_get_alias_set 
 #define LANG_HOOKS_MARK_ADDRESSABLE        gfc_mark_addressable
 #define LANG_HOOKS_TYPE_FOR_MODE           gfc_type_for_mode
 #define LANG_HOOKS_TYPE_FOR_SIZE           gfc_type_for_size
-#define LANG_HOOKS_CLEAR_BINDING_STACK     gfc_clear_binding_stack
 #define LANG_HOOKS_GET_ALIAS_SET	   gfc_get_alias_set
 #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE	gfc_omp_privatize_by_reference
 #define LANG_HOOKS_OMP_PREDETERMINED_SHARING	gfc_omp_predetermined_sharing
@@ -268,6 +266,8 @@ gfc_be_parse_file (int set_yydebug ATTRI
   gfc_get_errors (&warnings, &errors);
   errorcount += errors;
   warningcount += warnings;
+
+  gfc_clear_binding_stack ();
 }
 
 
Index: langhooks.h
===================================================================
--- langhooks.h	(revision 133001)
+++ langhooks.h	(working copy)
@@ -294,9 +294,6 @@ struct lang_hooks
      parsers to dump debugging information during parsing.  */
   void (*parse_file) (int);
 
-  /* Called immediately after parsing to clear the binding stack.  */
-  void (*clear_binding_stack) (void);
-
   /* Called to obtain the alias set to be used for an expression or type.
      Returns -1 if the language does nothing special for it.  */
   alias_set_type (*get_alias_set) (tree);
Index: langhooks-def.h
===================================================================
--- langhooks-def.h	(revision 133001)
+++ langhooks-def.h	(working copy)
@@ -85,7 +85,6 @@ extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_INIT			hook_bool_void_false
 #define LANG_HOOKS_FINISH		lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE		lhd_do_nothing_i
-#define LANG_HOOKS_CLEAR_BINDING_STACK	lhd_do_nothing
 #define LANG_HOOKS_INIT_OPTIONS		hook_uint_uint_constcharptrptr_0
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
 #define LANG_HOOKS_HANDLE_OPTION	hook_int_size_t_constcharptr_int_0
@@ -250,7 +249,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_INIT, \
   LANG_HOOKS_FINISH, \
   LANG_HOOKS_PARSE_FILE, \
-  LANG_HOOKS_CLEAR_BINDING_STACK, \
   LANG_HOOKS_GET_ALIAS_SET, \
   LANG_HOOKS_EXPAND_EXPR, \
   LANG_HOOKS_EXPAND_DECL, \

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