call.c (build_conditional_expr): Always use a TARGET_EXPR for class rvalues again.
authorJason Merrill <jason@yorick.cygnus.com>
Mon, 13 Sep 1999 10:12:07 +0000 (10:12 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 13 Sep 1999 10:12:07 +0000 (06:12 -0400)
* call.c (build_conditional_expr): Always use a TARGET_EXPR for
class rvalues again.

From-SVN: r29372

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

index 5d11fe63351bdbe339cd3069b38efce26bf3aedb..d2d8e7781eeaca98c66169a840c18985554ba4bd 100644 (file)
@@ -1,3 +1,8 @@
+1999-09-13  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * call.c (build_conditional_expr): Always use a TARGET_EXPR for
+       class rvalues again.
+
 Sun Sep 12 23:29:07 1999  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * Make-lang.in (g++spec.o): Depend on system.h and gcc.h.
index 12f4b9bc7e26251cde4729899a3f564011b8955b..bfc430de831c80e252cc5ee2728f5a4285cc7269 100644 (file)
@@ -2977,10 +2977,23 @@ build_conditional_expr (arg1, arg2, arg3)
 
      Lvalue-to-rvalue (_conv.lval_), array-to-pointer (_conv.array_),
      and function-to-pointer (_conv.func_) standard conversions are
-     performed on the second and third operands.  */
-  arg2 = decay_conversion (arg2);
+     performed on the second and third operands.
+
+     We need to force the lvalue-to-rvalue conversion here for class types,
+     so we get TARGET_EXPRs; trying to deal with a COND_EXPR of class rvalues
+     that isn't wrapped with a TARGET_EXPR plays havoc with exception
+     regions.  */
+
+  if (IS_AGGR_TYPE (TREE_TYPE (arg2)) && real_lvalue_p (arg2))
+    arg2 = build_user_type_conversion (TREE_TYPE (arg2), arg2, LOOKUP_NORMAL);
+  else
+    arg2 = decay_conversion (arg2);
   arg2_type = TREE_TYPE (arg2);
-  arg3 = decay_conversion (arg3);
+
+  if (IS_AGGR_TYPE (TREE_TYPE (arg3)) && real_lvalue_p (arg3))
+    arg3 = build_user_type_conversion (TREE_TYPE (arg3), arg3, LOOKUP_NORMAL);
+  else
+    arg3 = decay_conversion (arg3);
   arg3_type = TREE_TYPE (arg3);
 
   /* [expr.cond]
@@ -3061,8 +3074,9 @@ build_conditional_expr (arg1, arg2, arg3)
  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.  */
-  if (TREE_CODE (arg2) == TARGET_EXPR && TREE_CODE (arg3) == TARGET_EXPR)
+     ?: 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))
     {
       tree slot = build (VAR_DECL, result_type);
       layout_decl (slot, 0);