This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v2 of PATCH 08/14] cp/tree.c: strip location wrappers in lvalue_kind
- From: Jason Merrill <jason at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: Nathan Sidwell <nathan at acm dot org>, Jakub Jelinek <jakub at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 20 Dec 2017 23:56:17 -0500
- Subject: Re: [v2 of PATCH 08/14] cp/tree.c: strip location wrappers in lvalue_kind
- Authentication-results: sourceware.org; auth=none
- References: <4a709a4e-0c8e-da35-45d0-65ed5fe07167@redhat.com> <1513808092-23811-1-git-send-email-dmalcolm@redhat.com>
On Wed, Dec 20, 2017 at 5:14 PM, David Malcolm <dmalcolm@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