aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-09-28 15:39:45 -0400
committerJason Merrill <jason@gcc.gnu.org>2017-09-28 15:39:45 -0400
commit281e6c1d8f1b4ca552d8ce2276ddecfcd6ffb15e (patch)
tree4ec4cc5dfce6282bcbc8d1adfbbb092073395b53 /gcc/cp/decl2.c
parent5c263e84ab7e5df28a9055ae533c2d305f4b7b3d (diff)
downloadgcc-281e6c1d8f1b4ca552d8ce2276ddecfcd6ffb15e.zip
gcc-281e6c1d8f1b4ca552d8ce2276ddecfcd6ffb15e.tar.gz
gcc-281e6c1d8f1b4ca552d8ce2276ddecfcd6ffb15e.tar.bz2
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
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 03e91b7..29d6c59 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -427,6 +427,11 @@ grok_array_decl (location_t loc, tree array_expr, tree index_exp,
if (array_expr == error_mark_node || index_exp == error_mark_node)
error ("ambiguous conversion for array subscript");
+ if (TREE_CODE (TREE_TYPE (array_expr)) == POINTER_TYPE)
+ array_expr = mark_rvalue_use (array_expr);
+ else
+ array_expr = mark_lvalue_use_nonread (array_expr);
+ index_exp = mark_rvalue_use (index_exp);
expr = build_array_ref (input_location, array_expr, index_exp);
}
if (processing_template_decl && expr != error_mark_node)