Patch to save_expr_status

Jason Merrill jason@cygnus.com
Fri Oct 23 02:18:00 GMT 1998


Applied.  save_expr_status assumes that we only call it at places where
it's safe to emit the postincrement queue.  This is not the case for C++,
which may generate a new function in the middle of RTL expansion.

This fixes g++.other/badopt1.C.

Fri Oct 23 00:56:11 1998  Jason Merrill  <jason@yorick.cygnus.com>

	* expr.c (pending_chain): Move up.
	(save_expr_status): Do save pending_chain.
	(restore_expr_status): And restore it.
	* function.h (struct function): Add pending_chain.

Index: expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.c,v
retrieving revision 1.105
diff -c -p -r1.105 expr.c
*** expr.c	1998/10/13 15:25:11	1.105
--- expr.c	1998/10/23 07:57:03
*************** static int can_handle_constant_p;
*** 114,119 ****
--- 114,122 ----
     infinite recursion.  */
  static int in_check_memory_usage;
  
+ /* Postincrements that still need to be expanded.  */
+ static rtx pending_chain;
+ 
  /* This structure is used by move_by_pieces to describe the move to
     be performed.  */
  struct move_by_pieces
*************** void
*** 342,356 ****
  save_expr_status (p)
       struct function *p;
  {
!   /* Instead of saving the postincrement queue, empty it.  */
!   emit_queue ();
! 
    p->pending_stack_adjust = pending_stack_adjust;
    p->inhibit_defer_pop = inhibit_defer_pop;
    p->saveregs_value = saveregs_value;
    p->apply_args_value = apply_args_value;
    p->forced_labels = forced_labels;
  
    pending_stack_adjust = 0;
    inhibit_defer_pop = 0;
    saveregs_value = 0;
--- 345,358 ----
  save_expr_status (p)
       struct function *p;
  {
!   p->pending_chain = pending_chain;
    p->pending_stack_adjust = pending_stack_adjust;
    p->inhibit_defer_pop = inhibit_defer_pop;
    p->saveregs_value = saveregs_value;
    p->apply_args_value = apply_args_value;
    p->forced_labels = forced_labels;
  
+   pending_chain = NULL_RTX;
    pending_stack_adjust = 0;
    inhibit_defer_pop = 0;
    saveregs_value = 0;
*************** void
*** 365,370 ****
--- 367,373 ----
  restore_expr_status (p)
       struct function *p;
  {
+   pending_chain = p->pending_chain;
    pending_stack_adjust = p->pending_stack_adjust;
    inhibit_defer_pop = p->inhibit_defer_pop;
    saveregs_value = p->saveregs_value;
*************** restore_expr_status (p)
*** 374,381 ****
  
  /* Manage the queue of increment instructions to be output
     for POSTINCREMENT_EXPR expressions, etc.  */
- 
- static rtx pending_chain;
  
  /* Queue up to increment (or change) VAR later.  BODY says how:
     BODY should be the same thing you would pass to emit_insn
--- 377,382 ----
Index: function.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/function.h,v
retrieving revision 1.12
diff -c -p -r1.12 function.h
*** function.h	1998/10/11 02:21:33	1.12
--- function.h	1998/10/23 07:57:03
*************** struct function
*** 146,151 ****
--- 146,152 ----
    rtx ehc;
  
    /* For expr.c.  */
+   rtx pending_chain;
    int pending_stack_adjust;
    int inhibit_defer_pop;
    rtx saveregs_value;



More information about the Gcc-patches mailing list