On Wed, Dec 20, 2017 at 5:14 PM, David Malcolm <dmalc...@redhat.com> wrote: > On Mon, 2017-12-11 at 18:39 -0500, Jason Merrill wrote: >> On 11/10/2017 04:45 PM, David Malcolm wrote: >> > Without this, then lvalue_p returns false for decls, and hence >> > e.g. uses of them for references fail. >> > >> > Stripping location wrappers in lvalue_kind restores the correct >> > behavior of lvalue_p etc. >> > >> > gcc/cp/ChangeLog: >> > * tree.c (lvalue_kind): Strip any location wrapper. >> >> Rather, lvalue_kind should learn to handle VIEW_CONVERT_EXPR.
> This patch does so, using: > > case NON_LVALUE_EXPR: > case VIEW_CONVERT_EXPR: > if (location_wrapper_p (ref)) > return lvalue_kind (TREE_OPERAND (ref, 0)); > > As well as the VIEW_CONVERT_EXPR, lvalue_kind needs to handle > NON_LVALUE_EXPR, otherwise a location-wrapped string literal > hits this clause in the "default" case: > > if (CLASS_TYPE_P (TREE_TYPE (ref)) > || TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE) > return clk_class; > > when it should have hit this one (after removing the > location wrapper): > > case STRING_CST: > case COMPOUND_LITERAL_EXPR: > return clk_ordinary; Ah, the issue is that string literals should use VIEW_CONVERT_EXPR rather than NON_LVALUE_EXPR, since they are lvalues. With that change, we shouldn't need to handle NON_LVALUE_EXPR specifically. Jason