aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-08-19 21:45:44 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-08-19 21:45:44 -0400
commit18c4fa8ef0c5e3d705be8f50860b3e58be672256 (patch)
tree610e361af05e82acc2adedabe3bec485e19f5df2
parentf02fe7889f4dfd8bd3c8c020d10585026d46522a (diff)
downloadgcc-18c4fa8ef0c5e3d705be8f50860b3e58be672256.zip
gcc-18c4fa8ef0c5e3d705be8f50860b3e58be672256.tar.gz
gcc-18c4fa8ef0c5e3d705be8f50860b3e58be672256.tar.bz2
* lambda.c (current_nonlambda_scope): New.
From-SVN: r227022
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/lambda.c24
3 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e313e64..155f86a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2015-08-19 Jason Merrill <jason@redhat.com>
+
+ * lambda.c (current_nonlambda_scope): New.
+
2015-08-18 Trevor Saunders <tbsaunde@tbsaunde.org>
* call.c, class.c, cp-tree.h, decl.c, except.c, mangle.c,
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7cf5278..4dee60c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6308,6 +6308,7 @@ extern tree lambda_expr_this_capture (tree, bool);
extern tree maybe_resolve_dummy (tree, bool);
extern tree current_nonlambda_function (void);
extern tree nonlambda_method_basetype (void);
+extern tree current_nonlambda_scope (void);
extern void maybe_add_lambda_conv_op (tree);
extern bool is_lambda_ignored_entity (tree);
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index dcd3bb9..ea9dba0 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -817,6 +817,30 @@ nonlambda_method_basetype (void)
return TYPE_METHOD_BASETYPE (TREE_TYPE (fn));
}
+/* Like current_scope, but looking through lambdas. */
+
+tree
+current_nonlambda_scope (void)
+{
+ tree scope = current_scope ();
+ for (;;)
+ {
+ if (TREE_CODE (scope) == FUNCTION_DECL
+ && LAMBDA_FUNCTION_P (scope))
+ {
+ scope = CP_TYPE_CONTEXT (DECL_CONTEXT (scope));
+ continue;
+ }
+ else if (LAMBDA_TYPE_P (scope))
+ {
+ scope = CP_TYPE_CONTEXT (scope);
+ continue;
+ }
+ break;
+ }
+ return scope;
+}
+
/* Helper function for maybe_add_lambda_conv_op; build a CALL_EXPR with
indicated FN and NARGS, but do not initialize the return type or any of the
argument slots. */