Skip to content

Commit 5f76eee

Browse files
committed
c++, contracts: Recognise contract check scope for lambdas.
This allows lambdas to have default captures in the scope of contract pre/post-conditions. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
1 parent fd65ea5 commit 5f76eee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gcc/cp/parser.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11914,7 +11914,9 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
1191411914
first = false;
1191511915

1191611916
tree scope = current_nonlambda_scope (/*only_skip_closures_p=*/true);
11917-
if (TREE_CODE (scope) != FUNCTION_DECL && !parsing_nsdmi ())
11917+
if (TREE_CODE (scope) != FUNCTION_DECL
11918+
&& !parsing_nsdmi ()
11919+
&& current_binding_level->kind != sk_contract)
1191811920
error ("non-local lambda expression cannot have a capture-default");
1191911921
}
1192011922

0 commit comments

Comments
 (0)