diff options
| author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-05-22 22:28:24 +0000 |
|---|---|---|
| committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-05-22 22:28:24 +0000 |
| commit | 0c018b6fad1152159e90d0664f808503083eaa2f (patch) | |
| tree | 482d94f82159646fb44fea3724778df67a2b8f71 /gcc/cp | |
| parent | aa87aced5ba964ce66bb2b6ea135dae8d5879e58 (diff) | |
| download | gcc-0c018b6fad1152159e90d0664f808503083eaa2f.zip gcc-0c018b6fad1152159e90d0664f808503083eaa2f.tar.gz gcc-0c018b6fad1152159e90d0664f808503083eaa2f.tar.bz2 | |
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
Diffstat (limited to 'gcc/cp')
| -rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
| -rw-r--r-- | gcc/cp/lambda.c | 15 | ||||
| -rw-r--r-- | gcc/cp/typeck2.c | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2021e2d..a594e93 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index bb6014b..e72682c 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -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 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index e98942d..18bc25f 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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)); |
