From 76c7bf65e867b9acd70e13da15d07b51855f0cd4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 9 Jul 2013 17:55:49 +0200 Subject: [PATCH] re PR c++/53000 (Conditional operator does not behave as standardized) 2013-07-09 Marc Glisse PR c++/53000 gcc/cp/ * call.c (build_conditional_expr_1): Preserve xvalues. gcc/testsuite/ * g++.dg/cpp0x/decltype17.C: Adjust. From-SVN: r200821 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 9 +++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/decltype17.C | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 696ef35..6a04e58 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-07-09 Marc Glisse + + PR c++/53000 + * call.c (build_conditional_expr_1): Preserve xvalues. + 2013-07-09 Paolo Carlini PR c++/51786 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 425ef9b..78899ab 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4641,10 +4641,11 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, /* [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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e73706a..573d78a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-07-09 Marc Glisse + + PR c++/53000 + * g++.dg/cpp0x/decltype17.C: Adjust. + 2013-07-09 Paolo Carlini PR c++/51786 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype17.C b/gcc/testsuite/g++.dg/cpp0x/decltype17.C index 3c98105..7f36ff0 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype17.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype17.C @@ -24,6 +24,6 @@ int main() 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; } -- 2.7.4