c++: reject class lvalues in 'rvalue'
Wrapping a class lvalue in NON_LVALUE_EXPR is not sufficient to make it a usable prvalue; callers must use force_rvalue instead. gcc/cp/ChangeLog: * tree.c (rvalue): Assert expr is not a class lvalue.
This commit is contained in:
parent
fc17851977
commit
7a5dd3ed49
1 changed files with 6 additions and 1 deletions
|
@ -940,7 +940,12 @@ rvalue (tree 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 && glvalue_p (expr))
|
||||
expr = build1 (NON_LVALUE_EXPR, type, expr);
|
||||
{
|
||||
/* But don't use this function for class lvalues; use move (to treat an
|
||||
lvalue as an xvalue) or force_rvalue (to make a prvalue copy). */
|
||||
gcc_checking_assert (!CLASS_TYPE_P (type));
|
||||
expr = build1 (NON_LVALUE_EXPR, type, expr);
|
||||
}
|
||||
else if (type != TREE_TYPE (expr))
|
||||
expr = build_nop (type, expr);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue