[PATCH] Fix PR45569

Richard Guenther rguenther@suse.de
Tue Sep 7 12:33:00 GMT 2010


This fixes PR45569 - complex lowering wasn't caring for non-call 
exceptions and COMPLEX_EXPR or COSNTRUCTOR shouldn't ever trap.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-09-07  Richard Guenther  <rguenther@suse.de>

	PR middle-end/45569
	* tree-eh.c (operation_could_trap_helper_p): Neither COMPLEX_EXPR
	nor CONSTRUCTOR can trap.
	* tree-complex.c (update_complex_assignment): Update EH info.

	* g++.dg/eh/pr45569.C: New testcase.

Index: gcc/tree-eh.c
===================================================================
*** gcc/tree-eh.c	(revision 163941)
--- gcc/tree-eh.c	(working copy)
*************** operation_could_trap_helper_p (enum tree
*** 2334,2339 ****
--- 2334,2344 ----
  	return true;
        return false;
  
+     case COMPLEX_EXPR:
+     case CONSTRUCTOR:
+       /* Constructing an object cannot trap.  */
+       return false;
+ 
      default:
        /* Any floating arithmetic may trap.  */
        if (fp_operation && flag_trapping_math)
Index: gcc/tree-complex.c
===================================================================
*** gcc/tree-complex.c	(revision 163941)
--- gcc/tree-complex.c	(working copy)
*************** static void
*** 662,673 ****
  update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i)
  {
    gimple_stmt_iterator orig_si = *gsi;
  
    if (gimple_in_ssa_p (cfun))
      update_complex_components (gsi, gsi_stmt (*gsi), r, i);
  
    gimple_assign_set_rhs_with_ops (&orig_si, COMPLEX_EXPR, r, i);
!   update_stmt (gsi_stmt (orig_si));
  }
  
  
--- 662,677 ----
  update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i)
  {
    gimple_stmt_iterator orig_si = *gsi;
+   gimple stmt;
  
    if (gimple_in_ssa_p (cfun))
      update_complex_components (gsi, gsi_stmt (*gsi), r, i);
  
    gimple_assign_set_rhs_with_ops (&orig_si, COMPLEX_EXPR, r, i);
!   stmt = gsi_stmt (orig_si);
!   update_stmt (stmt);
!   if (maybe_clean_eh_stmt (stmt))
!     gimple_purge_dead_eh_edges (gimple_bb (stmt));
  }
  
  
Index: gcc/testsuite/g++.dg/eh/pr45569.C
===================================================================
*** gcc/testsuite/g++.dg/eh/pr45569.C	(revision 0)
--- gcc/testsuite/g++.dg/eh/pr45569.C	(revision 0)
***************
*** 0 ****
--- 1,23 ----
+ // { dg-do compile }
+ // { dg-options "-O -fnon-call-exceptions" }
+ 
+ float f ();
+ _Complex float g ();
+ 
+ void
+ i (_Complex float);
+ 
+ float j ()
+ {
+   _Complex float x = 0;
+   try
+     {
+       x = f ();
+     }
+   catch ( ...)
+     {
+       x += g ();
+     }
+   i (x);
+ }
+ 



More information about the Gcc-patches mailing list