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
This commit is contained in:
parent
7ca6f6d65a
commit
b9c6b842a9
4 changed files with 38 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
|||
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);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.
|
||||
|
||||
|
|
29
gcc/testsuite/g++.dg/cpp0x/decltype17.C
Normal file
29
gcc/testsuite/g++.dg/cpp0x/decltype17.C
Normal file
|
@ -0,0 +1,29 @@
|
|||
// 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue