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]

C++ PATCH to build_conditional_expr


The tree-ssa branch was failing g++.dg/eh/cond1.C because we were wrapping
a THROW_EXPR in a TARGET_EXPR, which doesn't make much sense.  Fixed thus.

Tested i686-pc-linux-gnu, applied to trunk and tree-ssa.

2003-05-07  Jason Merrill  <jason@redhat.com>

	* call.c (build_conditional_expr): Don't assume that the folded
	expression has result_type.

*** call.c.~1~	2003-05-07 00:55:03.000000000 -0400
--- call.c	2003-05-07 09:35:23.000000000 -0400
*************** build_conditional_expr (tree arg1, tree 
*** 3530,3545 ****
  
   valid_operands:
    result = fold (build (COND_EXPR, result_type, arg1, arg2, arg3));
    /* Expand both sides into the same slot, hopefully the target of the
       ?: expression.  We used to check for TARGET_EXPRs here, but now we
       sometimes wrap them in NOP_EXPRs so the test would fail.  */
!   if (!lvalue_p && IS_AGGR_TYPE (result_type))
!     result = build_target_expr_with_type (result, result_type);
    
    /* If this expression is an rvalue, but might be mistaken for an
       lvalue, we must add a NON_LVALUE_EXPR.  */
    if (!lvalue_p && real_lvalue_p (result))
!     result = build1 (NON_LVALUE_EXPR, result_type, result);
  
    return result;
  }
--- 3530,3548 ----
  
   valid_operands:
    result = fold (build (COND_EXPR, result_type, arg1, arg2, arg3));
+   /* We can't use result_type below, as fold might have returned a
+      throw_expr.  */
+ 
    /* Expand both sides into the same slot, hopefully the target of the
       ?: expression.  We used to check for TARGET_EXPRs here, but now we
       sometimes wrap them in NOP_EXPRs so the test would fail.  */
!   if (!lvalue_p && IS_AGGR_TYPE (TREE_TYPE (result)))
!     result = get_target_expr (result);
    
    /* If this expression is an rvalue, but might be mistaken for an
       lvalue, we must add a NON_LVALUE_EXPR.  */
    if (!lvalue_p && real_lvalue_p (result))
!     result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
  
    return result;
  }

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