On Thu, Nov 26, 2020 at 10:36:43AM +0100, Thomas Schwinge wrote:
> So, I understand, 'NON_LVALUE_EXPR's are primarily a C/C++ (only?) front
> end construct to wrap nodes that must not be used as a lvalue (per the
> programming language standards); rejecting code like 'int x; &(x + 0);',
> I suppose.

The NON_LVALUE_EXPRs serve two purposes, one is indeed to indicate something
is not an lvalue, even when its operand is, and another is holding location
info (I think currently only in the C++ FE), so that diagnostics can report
correct locations even for e.g. constants or uses of variables.
So, it is undesirable to avoid adding those location wrappers, but instead
when we want to look at the value of the expression we should be using
appropriate APIs (e.g. for_fold_warn, or maybe_constant_value).
And generally, cp_fold_function should be also stripping them away from
everything.

        Jakub

Reply via email to