re PR c++/78896 ([C++17] Segmentation fault occurs when use variable initialized using structured binding with capture-by-ref lambda)

PR c++/78896
	* decl.c (cp_finish_decomp): Disallow memberwise decomposition of
	lambda expressions.

	* g++.dg/cpp1z/decomp24.C: New test.

From-SVN: r244909
This commit is contained in:
Jakub Jelinek 2017-01-25 23:36:18 +01:00 committed by Jakub Jelinek
parent 0e3438689a
commit a25608aa6f
4 changed files with 23 additions and 0 deletions

View file

@ -1,5 +1,9 @@
2017-01-25 Jakub Jelinek <jakub@redhat.com>
PR c++/78896
* decl.c (cp_finish_decomp): Disallow memberwise decomposition of
lambda expressions.
PR c++/77914
* parser.c (cp_parser_lambda_declarator_opt): Pedwarn with
OPT_Wpedantic on lambda templates for -std=c++14 and higher.

View file

@ -7562,6 +7562,11 @@ cp_finish_decomp (tree decl, tree first, unsigned int count)
error_at (loc, "cannot decompose non-array non-class type %qT", type);
goto error_out;
}
else if (LAMBDA_TYPE_P (type))
{
error_at (loc, "cannot decompose lambda closure type %qT", type);
goto error_out;
}
else
{
tree btype = find_decomp_class_base (loc, type, NULL_TREE);

View file

@ -1,5 +1,8 @@
2017-01-25 Jakub Jelinek <jakub@redhat.com>
PR c++/78896
* g++.dg/cpp1z/decomp24.C: New test.
PR c++/77914
* g++.dg/cpp1y/lambda-generic-77914.C: New test.
* g++.dg/cpp1y/lambda-generic-dep.C: Add -pedantic to dg-options,

View file

@ -0,0 +1,11 @@
// PR c++/78896
// { dg-do compile { target c++11 } }
// { dg-options "" }
int
foo ()
{
int a {10};
auto [b] { [&a](){} }; // { dg-error "cannot decompose lambda closure type" }
return b - a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
}