PR c++/88613 - ICE with use of const var in lambda.
authorJason Merrill <jason@redhat.com>
Fri, 11 Jan 2019 22:36:20 +0000 (17:36 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 11 Jan 2019 22:36:20 +0000 (17:36 -0500)
commitf43e0585fab95e5cc2efac9aa26a8b74eeffbd71
tree3fc4cee14e318f3bf8b1fcb6ec63b532bfa104fc
parentda972c05f48637060ae3a3b121f99d1522413b82
PR c++/88613 - ICE with use of const var in lambda.

The issue here was that we were cp_folding a location wrapper around a
lambda capture proxy before it had been mark_rvalue_used.  I considered
adding mark_rvalue_use calls to build_new_op_1, but it seems appropriate to
have them in cp_fold_maybe_rvalue when we know we're trying to produce an
rvalue.

The change to mark_use is for a related issue: when we change the operand of
the location wrapper from VAR_DECL to INTEGER_CST, we need the TREE_CODE of
the location wrapper to change as well, from VIEW_CONVERT_EXPR to
NON_LVALUE_EXPR.

* expr.c (mark_use): Fix location wrapper handling.
* cp-gimplify.c (cp_fold_maybe_rvalue): Call mark_rvalue_use.

From-SVN: r267859
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/cp/expr.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const10.C [new file with mode: 0644]