Commit f7b9026e by Jason Merrill Committed by Jason Merrill

re PR c++/10245 (?: operator requires public copy constructor of return type)

        PR c++/10245
        * cvt.c (force_rvalue): New fn.
        * call.c (build_conditional_expr): Use it.
        * cp-tree.h: Declare it.

From-SVN: r65005
parent f7b4bc4d
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> 2003-03-28 Mike Stump <mrs@apple.com>
* error.c (dump_expr): Add 0x to printed hex numbers to make * error.c (dump_expr): Add 0x to printed hex numbers to make
......
...@@ -3418,18 +3418,10 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) ...@@ -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 We use ocp_convert rather than build_user_type_conversion because the
latter returns NULL_TREE on failure, while the former gives an error. */ latter returns NULL_TREE on failure, while the former gives an error. */
if (IS_AGGR_TYPE (TREE_TYPE (arg2))) arg2 = force_rvalue (arg2);
arg2 = ocp_convert (TREE_TYPE (arg2), arg2,
CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
else
arg2 = decay_conversion (arg2);
arg2_type = TREE_TYPE (arg2); arg2_type = TREE_TYPE (arg2);
if (IS_AGGR_TYPE (TREE_TYPE (arg3))) arg3 = force_rvalue (arg3);
arg3 = ocp_convert (TREE_TYPE (arg3), arg3,
CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
else
arg3 = decay_conversion (arg3);
arg3_type = TREE_TYPE (arg3); arg3_type = TREE_TYPE (arg3);
if (arg2 == error_mark_node || arg3 == error_mark_node) if (arg2 == error_mark_node || arg3 == error_mark_node)
......
...@@ -3647,6 +3647,7 @@ extern tree get_primary_binfo (tree); ...@@ -3647,6 +3647,7 @@ extern tree get_primary_binfo (tree);
extern tree convert_to_reference (tree, tree, int, int, tree); extern tree convert_to_reference (tree, tree, int, int, tree);
extern tree convert_from_reference (tree); extern tree convert_from_reference (tree);
extern tree convert_lvalue (tree, tree); extern tree convert_lvalue (tree, tree);
extern tree force_rvalue (tree);
extern tree ocp_convert (tree, tree, int, int); extern tree ocp_convert (tree, tree, int, int);
extern tree cp_convert (tree, tree); extern tree cp_convert (tree, tree);
extern tree convert_to_void (tree, const char */*implicit context*/); extern tree convert_to_void (tree, const char */*implicit context*/);
......
...@@ -573,6 +573,21 @@ convert_lvalue (tree totype, tree expr) ...@@ -573,6 +573,21 @@ convert_lvalue (tree totype, tree expr)
NULL_TREE); NULL_TREE);
return convert_from_reference (expr); 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;
}
/* C++ conversions, preference to static cast conversions. */ /* C++ conversions, preference to static cast conversions. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment