re PR c++/10245 (?: operator requires public copy constructor of return type)
authorJason Merrill <jason@redhat.com>
Sat, 29 Mar 2003 00:49:34 +0000 (19:49 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 29 Mar 2003 00:49:34 +0000 (19:49 -0500)
        PR c++/10245
        * cvt.c (force_rvalue): New fn.
        * call.c (build_conditional_expr): Use it.
        * cp-tree.h: Declare it.

From-SVN: r65005

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/cvt.c

index 2dc2bb7a2a9e0405466642349732fcd3a5ff728d..dcaf0e4a0a26c4deef3d81cc8044b83a6d30a401 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/10245
+       * cvt.c (force_rvalue): New fn.
+       * call.c (build_conditional_expr): Use it.
+       * cp-tree.h: Declare it.
+
 2003-03-28  Mike Stump  <mrs@apple.com>
 
        * error.c (dump_expr): Add 0x to printed hex numbers to make
index 101b3417435a6d1e11f0b0441078e51fb771d6ec..b2f9291139fdf103a2266a83423b0f3597a236a3 100644 (file)
@@ -3418,18 +3418,10 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
      We use ocp_convert rather than build_user_type_conversion because the
      latter returns NULL_TREE on failure, while the former gives an error.  */
 
-  if (IS_AGGR_TYPE (TREE_TYPE (arg2)))
-    arg2 = ocp_convert (TREE_TYPE (arg2), arg2,
-                       CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
-  else
-    arg2 = decay_conversion (arg2);
+  arg2 = force_rvalue (arg2);
   arg2_type = TREE_TYPE (arg2);
 
-  if (IS_AGGR_TYPE (TREE_TYPE (arg3)))
-    arg3 = ocp_convert (TREE_TYPE (arg3), arg3,
-                       CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
-  else
-    arg3 = decay_conversion (arg3);
+  arg3 = force_rvalue (arg3);
   arg3_type = TREE_TYPE (arg3);
 
   if (arg2 == error_mark_node || arg3 == error_mark_node)
index 82fc020e6308f8e80b0b79de77b836dc19748138..f4d9ab9c0239ee153d12e44fba64ea73ee9272e4 100644 (file)
@@ -3647,6 +3647,7 @@ extern tree get_primary_binfo                   (tree);
 extern tree convert_to_reference (tree, tree, int, int, tree);
 extern tree convert_from_reference (tree);
 extern tree convert_lvalue (tree, tree);
+extern tree force_rvalue (tree);
 extern tree ocp_convert (tree, tree, int, int);
 extern tree cp_convert (tree, tree);
 extern tree convert_to_void (tree, const char */*implicit context*/);
index 88e802e14b0a3cda258d1958d096fb99eda67e97..19bca82f07603d3e2c11d57d7d9db46097426e22 100644 (file)
@@ -573,6 +573,21 @@ convert_lvalue (tree totype, tree expr)
                               NULL_TREE);
   return convert_from_reference (expr);
 }
+
+/* Really perform an lvalue-to-rvalue conversion, including copying an
+   argument of class type into a temporary.  */
+
+tree
+force_rvalue (tree expr)
+{
+  if (IS_AGGR_TYPE (TREE_TYPE (expr)) && TREE_CODE (expr) != TARGET_EXPR)
+    expr = ocp_convert (TREE_TYPE (expr), expr,
+                       CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
+  else
+    expr = decay_conversion (expr);
+
+  return expr;
+}
 \f
 /* C++ conversions, preference to static cast conversions.  */