]> gcc.gnu.org Git - gcc.git/commit - gcc/cp/constexpr.cc
c++: discarded-value and constexpr
authorJason Merrill <jason@redhat.com>
Thu, 19 May 2022 16:24:33 +0000 (12:24 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 24 May 2022 19:50:26 +0000 (15:50 -0400)
commit72f76540ad0e7185d4f516e781e8bead13ebc170
tree843cb42d0a7025cb8cadc4432c64ba871a0e9587
parent2540e2c604142889308857657d3510874955336a
c++: discarded-value and constexpr

I've been thinking for a while that the 'lval' parameter needed a third
value for discarded-value expressions; most importantly,
cxx_eval_store_expression does extra work for an lvalue result, and we also
don't want to do the l->r conversion.

Mostly this is pretty mechanical.  Apart from the _store_ fix, I also use
vc_discard for substatements of a STATEMENT_LIST other than a stmt-expr
result, and avoid building _REFs to be ignored in a few other places.

gcc/cp/ChangeLog:

* constexpr.cc (enum value_cat): New. Change all 'lval' parameters
from int to value_cat.  Change most false to vc_prvalue, most true
to vc_glvalue, cases where the return value is ignored to
vc_discard.
(cxx_eval_statement_list): Only vc_prvalue for stmt-expr result.
(cxx_eval_store_expression): Only build _REF for vc_glvalue.
(cxx_eval_array_reference, cxx_eval_component_reference)
(cxx_eval_indirect_ref, cxx_eval_constant_expression): Likewise.
gcc/cp/constexpr.cc
This page took 0.060528 seconds and 5 git commands to generate.