Commit c965b169 by Jason Merrill Committed by Jason Merrill

re PR c++/9440 (error message about "non-lvalue in unary '&'" when using ?: operator)

        PR c++/9440
        * call.c (build_conditional_expr): Use convert rather than an
        explicit NOP_EXPR.

From-SVN: r63872
parent 98857de8
2003-03-05 Jason Merrill <jason@redhat.com>
PR c++/9440
* call.c (build_conditional_expr): Use convert rather than an
explicit NOP_EXPR.
2003-03-02 Matt Austern <austern@apple.com> 2003-03-02 Matt Austern <austern@apple.com>
* decl.c (cp_binding_level): Add static_decls varray member. * decl.c (cp_binding_level): Add static_decls varray member.
......
...@@ -3112,13 +3112,9 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) ...@@ -3112,13 +3112,9 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
arg2 = convert_from_reference (arg2); arg2 = convert_from_reference (arg2);
/* That may not quite have done the trick. If the two types /* That may not quite have done the trick. If the two types
are cv-qualified variants of one another, we will have are cv-qualified variants of one another, we will have
just used an IDENTITY_CONV. (There's no conversion from just used an IDENTITY_CONV. */
an lvalue of one class type to an lvalue of another type,
even a cv-qualified variant, and we don't want to lose
lvalue-ness here.) So, we manually add a NOP_EXPR here
if necessary. */
if (!same_type_p (TREE_TYPE (arg2), arg3_type)) if (!same_type_p (TREE_TYPE (arg2), arg3_type))
arg2 = build1 (NOP_EXPR, arg3_type, arg2); arg2 = convert (arg3_type, arg2);
arg2_type = TREE_TYPE (arg2); arg2_type = TREE_TYPE (arg2);
} }
else if (conv3 && !ICS_BAD_FLAG (conv3)) else if (conv3 && !ICS_BAD_FLAG (conv3))
...@@ -3126,7 +3122,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) ...@@ -3126,7 +3122,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
arg3 = convert_like (conv3, arg3); arg3 = convert_like (conv3, arg3);
arg3 = convert_from_reference (arg3); arg3 = convert_from_reference (arg3);
if (!same_type_p (TREE_TYPE (arg3), arg2_type)) if (!same_type_p (TREE_TYPE (arg3), arg2_type))
arg3 = build1 (NOP_EXPR, arg2_type, arg3); arg3 = convert (arg2_type, arg3);
arg3_type = TREE_TYPE (arg3); arg3_type = TREE_TYPE (arg3);
} }
} }
......
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