PR c++/56973, DR 696 - capture constant variables only as needed.
commit4cedc476c94a41551d965bc57fbbe0186983c3c4
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Sep 2017 19:39:45 +0000 (28 19:39 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Sep 2017 19:39:45 +0000 (28 19:39 +0000)
tree4ec4cc5dfce6282bcbc8d1adfbbb092073395b53
parent6f20c78581397079216efbe5edfd1800b2fd5988
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253266 138bc75d-0d04-0410-961f-82ee72b054a4
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