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]

Tidy add_scope_stmt


Hi,
The attached patch tidies add_scope_stmt to only call
current_scope_stmt_stack once.

What confused me originally was the line
       *current_scope_stmt_stack () 
 	= tree_cons (ss, NULL_TREE, *current_scope_stmt_stack ());

which calls it twice with no ordering on those calls.

built & tested on i686-pc-linux-gnu,ok for mainline?

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-04-23  Nathan Sidwell <nathan@codesourcery.com>

	* c-semantics.c (add_scope_stmt): Don't call
	current_scope_stmt_stack multiple times.

Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-semantics.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 c-semantics.c
*** c-semantics.c	2001/04/11 15:51:51	1.23
--- c-semantics.c	2001/04/23 13:07:43
*************** add_scope_stmt (begin_p, partial_p)
*** 113,120 ****
       int begin_p;
       int partial_p;
  {
    tree ss;
!   tree top;
  
    /* Build the statement.  */
    ss = build_stmt (SCOPE_STMT, NULL_TREE);
--- 113,121 ----
       int begin_p;
       int partial_p;
  {
+   tree *stack_ptr = current_scope_stmt_stack ();
    tree ss;
!   tree top = *stack_ptr;
  
    /* Build the statement.  */
    ss = build_stmt (SCOPE_STMT, NULL_TREE);
*************** add_scope_stmt (begin_p, partial_p)
*** 124,138 ****
    /* Keep the scope stack up to date.  */
    if (begin_p)
      {
!       *current_scope_stmt_stack () 
! 	= tree_cons (ss, NULL_TREE, *current_scope_stmt_stack ());
!       top = *current_scope_stmt_stack ();
      }
    else
      {
-       top = *current_scope_stmt_stack ();
        TREE_VALUE (top) = ss;
!       *current_scope_stmt_stack () = TREE_CHAIN (top);
      }
  
    /* Add the new statement to the statement-tree.  */
--- 125,137 ----
    /* Keep the scope stack up to date.  */
    if (begin_p)
      {
!       top = tree_cons (ss, NULL_TREE, top);
!       *stack_ptr = top;
      }
    else
      {
        TREE_VALUE (top) = ss;
!       *stack_ptr = TREE_CHAIN (top);
      }
  
    /* Add the new statement to the statement-tree.  */

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