summaryrefslogtreecommitdiff
path: root/gcc/cp/expr.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-11-20 16:02:55 +0000
committerRichard Sandiford <richard.sandiford@linaro.org>2017-11-20 16:02:55 +0000
commitd58952aefb03632bbb5b441d5c0bd330711f0af1 (patch)
treed046e56bfbd6a40106ae6ab96fafc954f1dfc955 /gcc/cp/expr.c
parent648f8fc59b2cc39abd24f4c22388b346cdebcc31 (diff)
parent50221fae802a10fafe95e61d40504a58da33e98f (diff)
downloadgcc-linaro-dev/sve.tar.gz
Merge trunk into svelinaro-dev/sve
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 23e30cf789c..81b9a5b1dc9 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);