aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/expr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-11-13 17:34:38 -0500
committerJason Merrill <jason@gcc.gnu.org>2017-11-13 17:34:38 -0500
commitc1051bf7d8c99d056c6ae3353eb2b61751293d2f (patch)
treefd734eba6bb7c4373c5a32b46fdb8e5256e42335 /gcc/cp/expr.c
parent04757a2a49bd21c71af386a64591f77c165a0d93 (diff)
downloadgcc-c1051bf7d8c99d056c6ae3353eb2b61751293d2f.zip
gcc-c1051bf7d8c99d056c6ae3353eb2b61751293d2f.tar.gz
gcc-c1051bf7d8c99d056c6ae3353eb2b61751293d2f.tar.bz2
Capture adjustments for P0588R1.
* semantics.c (process_outer_var_ref): Capture variables when they are named; complain about non-capture uses when odr-used. * expr.c (mark_use): Rvalue use looks through capture proxy. * constexpr.c (potential_constant_expression_1): Improve error about use of captured variable. * lambda.c (need_generic_capture, dependent_capture_r) (do_dependent_capture, processing_nonlambda_template): Remove. * call.c (build_this): Remove uses of the above. * decl.c (cp_finish_decl): Likewise. * semantics.c (maybe_cleanup_point_expr) (maybe_cleanup_point_expr_void, finish_goto_stmt) (maybe_convert_cond): Likewise. * typeck.c (check_return_expr): Likewise. From-SVN: r254713
Diffstat (limited to 'gcc/cp/expr.c')
-rw-r--r--gcc/cp/expr.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c
index 23e30cf..81b9a5b 100644
--- a/gcc/cp/expr.c
+++ b/gcc/cp/expr.c
@@ -111,6 +111,14 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
{
case VAR_DECL:
case PARM_DECL:
+ if (rvalue_p && is_normal_capture_proxy (expr))
+ {
+ /* Look through capture by copy. */
+ tree cap = DECL_CAPTURED_VARIABLE (expr);
+ if (TREE_CODE (TREE_TYPE (cap)) == TREE_CODE (TREE_TYPE (expr))
+ && decl_constant_var_p (cap))
+ return RECUR (cap);
+ }
if (outer_automatic_var_p (expr)
&& decl_constant_var_p (expr))
{
@@ -146,6 +154,14 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
{
/* Try to look through the reference. */
tree ref = TREE_OPERAND (expr, 0);
+ if (rvalue_p && is_normal_capture_proxy (ref))
+ {
+ /* Look through capture by reference. */
+ tree cap = DECL_CAPTURED_VARIABLE (ref);
+ if (TREE_CODE (TREE_TYPE (cap)) != REFERENCE_TYPE
+ && decl_constant_var_p (cap))
+ return RECUR (cap);
+ }
tree r = mark_rvalue_use (ref, loc, reject_builtin);
if (r != ref)
expr = convert_from_reference (r);