This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Preserve xvalues in ?:
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jason at redhat dot com
- Date: Sun, 7 Jul 2013 16:02:40 +0200 (CEST)
- Subject: Preserve xvalues in ?:
Hello,
this patch gets us one line closer to implementing the proper C++11
semantics for ?: (there are still quite a few missing).
Bootstrap+testsuite on x86_64-unknown-linux-gnu.
2013-07-07 Marc Glisse <marc.glisse@inria.fr>
PR c++/53000
gcc/cp/
* call.c (build_conditional_expr_1): Preserve xvalues.
gcc/testsuite/
* g++.dg/cpp0x/decltype17.C: Adjust.
--
Marc Glisse
Index: testsuite/g++.dg/cpp0x/decltype17.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype17.C (revision 200742)
+++ testsuite/g++.dg/cpp0x/decltype17.C (working copy)
@@ -17,13 +17,13 @@ decltype(true ? lvalueref() : lvalueref(
decltype(true ? rvalueref() : rvalueref()) h()
{}
int main()
{
if (strcmp (typeid(f).name(), "FivE") != 0)
return 1;
if (strcmp (typeid(g).name(), "FRivE") != 0)
return 2;
- if (strcmp (typeid(h).name(), "FivE") != 0)
+ if (strcmp (typeid(h).name(), "FOivE") != 0)
return 3;
}
Index: cp/call.c
===================================================================
--- cp/call.c (revision 200742)
+++ cp/call.c (working copy)
@@ -4634,24 +4634,25 @@ build_conditional_expr_1 (location_t loc
&& CLASS_TYPE_P (arg2_type)
&& cp_type_quals (arg2_type) != cp_type_quals (arg3_type))
arg2_type = arg3_type =
cp_build_qualified_type (arg2_type,
cp_type_quals (arg2_type)
| cp_type_quals (arg3_type));
}
/* [expr.cond]
- If the second and third operands are lvalues and have the same
- type, the result is of that type and is an lvalue. */
- if (real_lvalue_p (arg2)
- && real_lvalue_p (arg3)
+ If the second and third operands are glvalues of the same value
+ category and have the same type, the result is of that type and
+ value category. */
+ if (((real_lvalue_p (arg2) && real_lvalue_p (arg3))
+ || (xvalue_p (arg2) && xvalue_p (arg3)))
&& same_type_p (arg2_type, arg3_type))
{
result_type = arg2_type;
arg2 = mark_lvalue_use (arg2);
arg3 = mark_lvalue_use (arg3);
goto valid_operands;
}
/* [expr.cond]