Commit 3983063e by Jason Merrill Committed by Jason Merrill

CWG 616, 1213 - value category of subobject references.

	* tree.c (lvalue_kind): Fix handling of ARRAY_REF of pointer.

From-SVN: r260780
parent 9d502741
2018-05-25 Jason Merrill <jason@redhat.com>
CWG 616, 1213 - value category of subobject references.
* tree.c (lvalue_kind): Fix handling of ARRAY_REF of pointer.
2018-05-24 Jason Merrill <jason@redhat.com> 2018-05-24 Jason Merrill <jason@redhat.com>
PR c++/85842 - -Wreturn-type, constexpr if and generic lambda. PR c++/85842 - -Wreturn-type, constexpr if and generic lambda.
......
...@@ -95,14 +95,24 @@ lvalue_kind (const_tree ref) ...@@ -95,14 +95,24 @@ lvalue_kind (const_tree ref)
case TRY_CATCH_EXPR: case TRY_CATCH_EXPR:
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
case ARRAY_REF:
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0)); return lvalue_kind (TREE_OPERAND (ref, 0));
if (op1_lvalue_kind == clk_class)
/* in the case of an array operand, the result is an lvalue if that case ARRAY_REF:
operand is an lvalue and an xvalue otherwise */ {
op1_lvalue_kind = clk_rvalueref; tree op1 = TREE_OPERAND (ref, 0);
return op1_lvalue_kind; if (TREE_CODE (TREE_TYPE (op1)) == ARRAY_TYPE)
{
op1_lvalue_kind = lvalue_kind (op1);
if (op1_lvalue_kind == clk_class)
/* in the case of an array operand, the result is an lvalue if
that operand is an lvalue and an xvalue otherwise */
op1_lvalue_kind = clk_rvalueref;
return op1_lvalue_kind;
}
else
return clk_ordinary;
}
case MEMBER_REF: case MEMBER_REF:
case DOTSTAR_EXPR: case DOTSTAR_EXPR:
......
int *g();
template <class T>
void f(int i)
{
int *p = &g()[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