Message ID | 15811e27-2bac-382a-ae3c-ff37fa7925fb@oracle.com |
---|---|
State | New |
Headers | show |
OK. On Thu, Aug 4, 2016 at 1:02 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > > when back in 2014 I sent the patch for c++/61088 I noticed some cases where > we wanted to return early error_mark_node from add_capture to avoid ICEs > during error recovery when COMPLETE_TYPE_P is used on an error_mark_node. > The new testcase noticed one additional case, where the error_mark_node is > returned by lambda_capture_field_type. I propose to just immediately check > it. Alternately we could add the check to the else branch of the following > conditional (which also passes testing) or somewhere else too, I guess. > Tested x86_64-linux. > > Thanks, > > Paolo. > > //////////////////////// >
Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 239118) +++ cp/lambda.c (working copy) @@ -492,6 +492,8 @@ add_capture (tree lambda, tree id, tree orig_init, else { type = lambda_capture_field_type (initializer, explicit_init_p); + if (type == error_mark_node) + return error_mark_node; if (by_reference_p) { type = build_reference_type (type); Index: testsuite/g++.dg/cpp1y/lambda-ice1.C =================================================================== --- testsuite/g++.dg/cpp1y/lambda-ice1.C (revision 0) +++ testsuite/g++.dg/cpp1y/lambda-ice1.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/72800 +// { dg-do compile { target c++14 } } + +void foo () +{ + [n {}] {}; // { dg-error "one element|deducing" } +}