Commit b9c6b842 by Jason Merrill Committed by Jason Merrill

re PR c++/36628 ([c++0x] incorrect decltype() handling of conditional operator)

	PR c++/36628
	* tree.c (rvalue): Use lvalue_or_rvalue_with_address_p.

From-SVN: r149536
parent 7ca6f6d6
2009-07-12 Jason Merrill <jason@redhat.com>
PR c++/36628
* tree.c (rvalue): Use lvalue_or_rvalue_with_address_p.
PR c++/37206
* cp-tree.h (enum cp_lvalue_kind_flags): Add clk_rvalueref.
* tree.c (lvalue_p_1): Return it. Remove
......
......@@ -532,7 +532,9 @@ rvalue (tree expr)
if (!CLASS_TYPE_P (type) && cp_type_quals (type))
type = TYPE_MAIN_VARIANT (type);
if (!processing_template_decl && real_lvalue_p (expr))
/* We need to do this for rvalue refs as well to get the right answer
from decltype; see c++/36628. */
if (!processing_template_decl && lvalue_or_rvalue_with_address_p (expr))
expr = build1 (NON_LVALUE_EXPR, type, expr);
else if (type != TREE_TYPE (expr))
expr = build_nop (type, expr);
......
2009-07-12 Jason Merrill <jason@redhat.com>
PR c++/36628
* g++.dg/cpp0x/decltype17.C: New.
PR c++/37206
* g++.dg/cpp0x/rv10.C: New.
......
// PR c++/36628
// { dg-options "-std=c++0x" }
// { dg-do run }
#include <typeinfo>
#include <string.h>
int rvalue();
int& lvalueref();
int&& rvalueref();
decltype(true ? rvalue() : rvalue()) f()
{}
decltype(true ? lvalueref() : lvalueref()) g()
{}
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)
return 3;
}
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