diff options
author | Jason Merrill <jason@redhat.com> | 2019-01-11 17:36:20 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-01-11 17:36:20 -0500 |
commit | f43e0585fab95e5cc2efac9aa26a8b74eeffbd71 (patch) | |
tree | 3fc4cee14e318f3bf8b1fcb6ec63b532bfa104fc /gcc/cp/expr.c | |
parent | da972c05f48637060ae3a3b121f99d1522413b82 (diff) | |
download | gcc-f43e0585fab95e5cc2efac9aa26a8b74eeffbd71.zip gcc-f43e0585fab95e5cc2efac9aa26a8b74eeffbd71.tar.gz gcc-f43e0585fab95e5cc2efac9aa26a8b74eeffbd71.tar.bz2 |
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
Diffstat (limited to 'gcc/cp/expr.c')
-rw-r--r-- | gcc/cp/expr.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index 071c6fb..9160043 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -187,10 +187,23 @@ mark_use (tree expr, bool rvalue_p, bool read_p, } break; - CASE_CONVERT: case VIEW_CONVERT_EXPR: if (location_wrapper_p (expr)) - loc = EXPR_LOCATION (expr); + { + loc = EXPR_LOCATION (expr); + tree op = TREE_OPERAND (expr, 0); + tree nop = RECUR (op); + if (nop == error_mark_node) + return error_mark_node; + TREE_OPERAND (expr, 0) = nop; + /* If we're replacing a DECL with a constant, we also need to change + the TREE_CODE of the location wrapper. */ + if (op != nop && rvalue_p) + TREE_SET_CODE (expr, NON_LVALUE_EXPR); + return expr; + } + gcc_fallthrough(); + CASE_CONVERT: recurse_op[0] = true; break; |