PR c++/56973, DR 696 - capture constant variables only as needed.
authorJason Merrill <jason@redhat.com>
Thu, 28 Sep 2017 19:39:45 +0000 (15:39 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 28 Sep 2017 19:39:45 +0000 (15:39 -0400)
commit281e6c1d8f1b4ca552d8ce2276ddecfcd6ffb15e
tree4ec4cc5dfce6282bcbc8d1adfbbb092073395b53
parent5c263e84ab7e5df28a9055ae533c2d305f4b7b3d
PR c++/56973, DR 696 - capture constant variables only as needed.

* expr.c (mark_use): Split out from mark_rvalue_use and
mark_lvalue_use.  Handle lambda capture of constant variables.
(mark_lvalue_use_nonread): New.
* semantics.c (process_outer_var_ref): Don't capture a constant
variable until forced.
* pt.c (processing_nonlambda_template): New.
* call.c (build_this): Check it.
* decl2.c (grok_array_decl): Call mark_rvalue_use and
mark_lvalue_use_nonread.
* init.c (constant_value_1): Don't call mark_rvalue_use.
* typeck.c (build_static_cast): Handle lambda capture.

From-SVN: r253266
13 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/expr.c
gcc/cp/init.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/constexpr-64462.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/lambda-generic-const4.C