re PR c++/61088 (segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array)
/cp 2014-05-22 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61088 * lambda.c (add_capture): Enforce that capture by value requires complete type. * typeck2.c (cxx_incomplete_type_inform): Early return if TYPE_MAIN_DECL is null. /testsuite 2014-05-22 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61088 * g++.dg/cpp0x/lambda/lambda-ice13.C: New. * g++.dg/cpp0x/lambda/lambda-ice7.C: Adjust. From-SVN: r210829
This commit is contained in:
parent
aa87aced5b
commit
0c018b6fad
@ -1,3 +1,11 @@
|
||||
2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/61088
|
||||
* lambda.c (add_capture): Enforce that capture by value requires
|
||||
complete type.
|
||||
* typeck2.c (cxx_incomplete_type_inform): Early return if
|
||||
TYPE_MAIN_DECL is null.
|
||||
|
||||
2014-05-21 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR c/61271
|
||||
|
@ -453,6 +453,9 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
|
||||
initializer = build_x_compound_expr_from_list (initializer, ELK_INIT,
|
||||
tf_warning_or_error);
|
||||
type = TREE_TYPE (initializer);
|
||||
if (type == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
if (array_of_runtime_bound_p (type))
|
||||
{
|
||||
vla = true;
|
||||
@ -489,8 +492,16 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
|
||||
error ("cannot capture %qE by reference", initializer);
|
||||
}
|
||||
else
|
||||
/* Capture by copy requires a complete type. */
|
||||
type = complete_type (type);
|
||||
{
|
||||
/* Capture by copy requires a complete type. */
|
||||
type = complete_type (type);
|
||||
if (!dependent_type_p (type) && !COMPLETE_TYPE_P (type))
|
||||
{
|
||||
error ("capture by copy of incomplete type %qT", type);
|
||||
cxx_incomplete_type_inform (type);
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add __ to the beginning of the field name so that user code
|
||||
|
@ -434,6 +434,9 @@ abstract_virtuals_error (abstract_class_use use, tree type)
|
||||
void
|
||||
cxx_incomplete_type_inform (const_tree type)
|
||||
{
|
||||
if (!TYPE_MAIN_DECL (type))
|
||||
return;
|
||||
|
||||
location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
|
||||
tree ptype = strip_top_quals (CONST_CAST_TREE (type));
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/61088
|
||||
* g++.dg/cpp0x/lambda/lambda-ice13.C: New.
|
||||
* g++.dg/cpp0x/lambda/lambda-ice7.C: Adjust.
|
||||
|
||||
2014-05-22 Xinliang David Li <davidxl@google.com>
|
||||
|
||||
* g++.dg/ipa/devirt-15.C: Fix expected message.
|
||||
|
14
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
Normal file
14
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
Normal file
@ -0,0 +1,14 @@
|
||||
// PR c++/61088
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
void f()
|
||||
{
|
||||
typedef void (*X) ();
|
||||
X x[] = { [x](){} }; // { dg-error "incomplete type" }
|
||||
}
|
||||
|
||||
void g()
|
||||
{
|
||||
typedef void (X) ();
|
||||
X x[] = { [x](){} }; // { dg-error "array of functions|not declared" }
|
||||
}
|
@ -5,5 +5,5 @@ struct A; // { dg-message "forward declaration" }
|
||||
|
||||
void foo(A& a)
|
||||
{
|
||||
[=](){a;}; // { dg-error "invalid use of incomplete type" }
|
||||
[=](){a;}; // { dg-error "incomplete type" }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user