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]

PATCH for minor C++ cleanups



This patch just does a little cleanup (commonizing code) to simplify
the code that will build the whole-function representation.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-08-11  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (minimal_parse_mode): Remove.
	(finish_label_stmt): New function.
	* decl.c (saved_scope): Remove minimal parse mode.
	(maybe_push_to_top_level): Don't save it.
	(pop_from_top_level): Don't restore it.
	(define_label): Split out template-handling code to semantics.c.
	(start_decl): Don't use minimal_parse_mode.
	(cp_finish_decl): Likewise.
	(start_function): Don't increment it.
	(store_return_init): Don't use it.
	(finish_function): Don't decrement it.
	* parse.y (label_colon): Use finish_label_stmt throughout.
	* parse.c: Regenerated.
	* pt.c (minimal_parse_mode): Don't define it.
	(tsubst_expr): Use finish_label_stmt.
	* semantics.c (finish_label_stmt): New function.

Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.259
diff -c -p -r1.259 cp-tree.h
*** cp-tree.h	1999/08/11 20:22:23	1.259
--- cp-tree.h	1999/08/12 01:39:35
*************** struct tinst_level
*** 2262,2269 ****
    struct tinst_level *next;
  };
  
- extern int minimal_parse_mode;
- 
  extern void maybe_print_template_context	PROTO ((void));
  
  /* in class.c */
--- 2263,2268 ----
*************** extern void finish_handler              
*** 3305,3310 ****
--- 3304,3310 ----
  extern tree begin_compound_stmt                 PROTO((int));
  extern tree finish_compound_stmt                PROTO((int, tree));
  extern void finish_asm_stmt                     PROTO((tree, tree, tree, tree, tree));
+ extern void finish_label_stmt                   PROTO((tree));
  extern tree finish_parenthesized_expr           PROTO((tree));
  extern tree begin_stmt_expr                     PROTO((void));
  extern tree finish_stmt_expr                    PROTO((tree, tree));
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.403
diff -c -p -r1.403 decl.c
*** decl.c	1999/08/11 20:22:25	1.403
--- decl.c	1999/08/12 01:39:44
*************** struct saved_scope {
*** 2390,2396 ****
    struct binding_level *class_bindings;
    tree *lang_base, *lang_stack, lang_name;
    int lang_stacksize;
-   int minimal_parse_mode;
    tree last_function_parms;
    tree template_parms;
    HOST_WIDE_INT processing_template_decl;
--- 2390,2395 ----
*************** maybe_push_to_top_level (pseudo)
*** 2509,2515 ****
    s->lang_base = current_lang_base;
    s->lang_stacksize = current_lang_stacksize;
    s->lang_name = current_lang_name;
-   s->minimal_parse_mode = minimal_parse_mode;
    s->last_function_parms = last_function_parms;
    s->template_parms = current_template_parms;
    s->processing_template_decl = processing_template_decl;
--- 2508,2513 ----
*************** maybe_push_to_top_level (pseudo)
*** 2529,2535 ****
    strict_prototype = strict_prototypes_lang_cplusplus;
    named_labels = NULL_TREE;
    shadowed_labels = NULL_TREE;
-   minimal_parse_mode = 0;
    previous_class_type = previous_class_values = NULL_TREE;
    class_cache_firstobj = 0;
    processing_specialization = 0;
--- 2527,2532 ----
*************** pop_from_top_level ()
*** 2595,2601 ****
      strict_prototype = strict_prototypes_lang_cplusplus;
    else if (current_lang_name == lang_name_c)
      strict_prototype = strict_prototypes_lang_c;
-   minimal_parse_mode = s->minimal_parse_mode;
    last_function_parms = s->last_function_parms;
    current_template_parms = s->template_parms;
    processing_template_decl = s->processing_template_decl;
--- 2592,2597 ----
*************** define_label (filename, line, name)
*** 4825,4845 ****
       int line;
       tree name;
  {
!   tree decl;
  
-   if (minimal_parse_mode)
-     {
-       push_obstacks (&permanent_obstack, &permanent_obstack);
-       decl = build_decl (LABEL_DECL, name, void_type_node);
-       pop_obstacks ();
-       DECL_SOURCE_LINE (decl) = line;
-       DECL_SOURCE_FILE (decl) = filename;
-       add_tree (decl);
-       return decl;
-     }
- 
-   decl = lookup_label (name);
- 
    /* After labels, make any new cleanups go into their
       own new (temporary) binding contour.  */
    current_binding_level->more_cleanups_ok = 0;
--- 4821,4828 ----
       int line;
       tree name;
  {
!   tree decl = lookup_label (name);
  
    /* After labels, make any new cleanups go into their
       own new (temporary) binding contour.  */
    current_binding_level->more_cleanups_ok = 0;
*************** start_decl (declarator, declspecs, initi
*** 7027,7033 ****
      {
        if (! current_function_decl)
  	tem = push_template_decl (tem);
!       else if (minimal_parse_mode)
  	DECL_VINDEX (tem)
  	    = build_min_nt (DECL_STMT, copy_to_permanent (declarator),
  			    copy_to_permanent (declspecs),
--- 7010,7016 ----
      {
        if (! current_function_decl)
  	tem = push_template_decl (tem);
!       else
  	DECL_VINDEX (tem)
  	    = build_min_nt (DECL_STMT, copy_to_permanent (declarator),
  			    copy_to_permanent (declspecs),
*************** cp_finish_decl (decl, init, asmspec_tree
*** 7398,7404 ****
      {
        if (init && DECL_INITIAL (decl))
  	DECL_INITIAL (decl) = init;
!       if (minimal_parse_mode && ! DECL_ARTIFICIAL (decl))
  	{
  	  tree stmt = DECL_VINDEX (decl);
  	  /* If the decl is declaring a member of a local class (in a
--- 7381,7387 ----
      {
        if (init && DECL_INITIAL (decl))
  	DECL_INITIAL (decl) = init;
!       if (current_function_decl && ! DECL_ARTIFICIAL (decl))
  	{
  	  tree stmt = DECL_VINDEX (decl);
  	  /* If the decl is declaring a member of a local class (in a
*************** start_function (declspecs, declarator, a
*** 13172,13182 ****
      temporary_allocation ();
  
    if (processing_template_decl)
!     {
!       ++minimal_parse_mode;
!       last_tree = DECL_SAVED_TREE (decl1)
! 	= build_nt (EXPR_STMT, void_zero_node);
!     }
  
    ++function_depth;
  
--- 13155,13162 ----
      temporary_allocation ();
  
    if (processing_template_decl)
!     last_tree = DECL_SAVED_TREE (decl1)
!       = build_nt (EXPR_STMT, void_zero_node);
  
    ++function_depth;
  
*************** store_return_init (return_id, init)
*** 13420,13426 ****
        DECL_INITIAL (decl) = init;
        pushdecl (decl);
  
!       if (minimal_parse_mode)
  	add_tree (build_min_nt (RETURN_INIT, return_id,
  				copy_to_permanent (init)));
        else
--- 13400,13406 ----
        DECL_INITIAL (decl) = init;
        pushdecl (decl);
  
!       if (processing_template_decl && current_function_decl)
  	add_tree (build_min_nt (RETURN_INIT, return_id,
  				copy_to_permanent (init)));
        else
*************** finish_function (lineno, flags, nested)
*** 13872,13878 ****
       until we do an instantiation.  */
    if (processing_template_decl)
      {
-       --minimal_parse_mode;
        DECL_SAVED_TREE (fndecl) = TREE_CHAIN (DECL_SAVED_TREE (fndecl));
        /* We have to save this value here in case
  	 maybe_end_member_template_processing decides to pop all the
--- 13852,13857 ----
Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/parse.y,v
retrieving revision 1.131
diff -c -p -r1.131 parse.y
*** parse.y	1999/08/11 20:31:35	1.131
--- parse.y	1999/08/12 01:39:51
*************** handler_args:
*** 3397,3414 ****
  
  label_colon:
  	  IDENTIFIER ':'
! 		{ tree label;
! 		do_label:
! 		  label = define_label (input_filename, lineno, $1);
! 		  if (label && ! minimal_parse_mode)
! 		    expand_label (label);
! 		}
  	| PTYPENAME ':'
! 		{ goto do_label; }
  	| TYPENAME ':'
! 		{ goto do_label; }
  	| SELFNAME ':'
! 		{ goto do_label; }
  	;
  
  for.init.statement:
--- 3397,3409 ----
  
  label_colon:
  	  IDENTIFIER ':'
!                 { finish_label_stmt ($1); }
  	| PTYPENAME ':'
!                 { finish_label_stmt ($1); }
  	| TYPENAME ':'
!                 { finish_label_stmt ($1); }
  	| SELFNAME ':'
!                 { finish_label_stmt ($1); }
  	;
  
  for.init.statement:
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.324
diff -c -p -r1.324 pt.c
*** pt.c	1999/08/09 10:44:54	1.324
--- pt.c	1999/08/12 01:39:56
*************** static tree *template_tail = &pending_te
*** 68,75 ****
  static tree maybe_templates;
  static tree *maybe_template_tail = &maybe_templates;
  
- int minimal_parse_mode;
- 
  int processing_specialization;
  int processing_explicit_instantiation;
  int processing_template_parmlist;
--- 68,73 ----
*************** tsubst_expr (t, args, complain, in_decl)
*** 7233,7242 ****
        break;
  
      case LABEL_DECL:
!       t = define_label (DECL_SOURCE_FILE (t), DECL_SOURCE_LINE (t),
! 			DECL_NAME (t));
!       if (t)
! 	expand_label (t);
        break;
  
      case GOTO_STMT:
--- 7231,7239 ----
        break;
  
      case LABEL_DECL:
!       lineno = DECL_SOURCE_LINE (t);
!       input_filename = DECL_SOURCE_FILE (t);
!       finish_label_stmt (DECL_NAME (t));
        break;
  
      case GOTO_STMT:
Index: semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.57
diff -c -p -r1.57 semantics.c
*** semantics.c	1999/08/11 20:22:38	1.57
--- semantics.c	1999/08/12 01:39:57
*************** finish_asm_stmt (cv_qualifier, string, o
*** 832,837 ****
--- 832,863 ----
      }
  }
  
+ /* Finish a label with the indicated NAME.  */
+ 
+ void
+ finish_label_stmt (name)
+      tree name;
+ {
+   tree decl;
+ 
+   if (processing_template_decl)
+     {
+       push_obstacks_nochange ();
+       end_temporary_allocation ();
+       decl = build_decl (LABEL_DECL, name, void_type_node);
+       pop_obstacks ();
+       DECL_SOURCE_LINE (decl) = lineno;
+       DECL_SOURCE_FILE (decl) = input_filename;
+       add_tree (decl);
+     }
+   else
+     {
+       decl = define_label (input_filename, lineno, name);
+       if (decl)
+ 	expand_label (decl);
+     }
+ }
+ 
  /* Finish a parenthesized expression EXPR.  */
  
  tree


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