call.c (build_conditional_expr): Don't assume that the folded expression has result_type.
authorJason Merrill <jason@redhat.com>
Wed, 7 May 2003 15:00:10 +0000 (11:00 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 7 May 2003 15:00:10 +0000 (11:00 -0400)
        * call.c (build_conditional_expr): Don't assume that the folded
        expression has result_type.

From-SVN: r66561

gcc/cp/ChangeLog
gcc/cp/call.c

index 15ca7a65013310171693e48cfd7fd3beeea49b39..4955d64a83e21283beac9f185c763daf0ffbec0e 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-07  Jason Merrill  <jason@redhat.com>
+
+       * call.c (build_conditional_expr): Don't assume that the folded
+       expression has result_type.
+
 2003-05-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * typeck.c (build_unary_op): Deal with const qualifier in
index 44683ff5b83401eb929dd9bd2aa70d567654aaab..5d7e3dfe963829f976d83897a124818b07092088 100644 (file)
@@ -3530,16 +3530,19 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
 
  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 (result_type))
-    result = build_target_expr_with_type (result, result_type);
+  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, result_type, result);
+    result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
 
   return result;
 }