Message ID | 56593f23-748c-fd5f-9cad-0ba3fc4118ce@oracle.com |
---|---|
State | New |
Headers | show |
OK; this is trivial enough for 6/7/8. On Wed, Jul 26, 2017 at 2:49 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > > avoiding the error recovery issues noticed in the bug seems just matter of > early returning error_mark_node from add_capture, like we already do a few > lines below in a similar case of ill-formed capture. Tested x86_64-linux. If > we are going to fix this in a simply way, maybe we could also backport to > 7... > > Thanks, Paolo. > > //////////////////// >
Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 250586) +++ cp/lambda.c (working copy) @@ -529,7 +529,10 @@ add_capture (tree lambda, tree id, tree orig_init, else if (id != this_identifier && by_reference_p) { if (!lvalue_p (initializer)) - error ("cannot capture %qE by reference", initializer); + { + error ("cannot capture %qE by reference", initializer); + return error_mark_node; + } } else { Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/71570 +// { dg-do compile { target c++11 } } + +void foo (int); + +void foo (void) +{ + [&foo] // { dg-error "cannot capture" } + { + foo (0); + }; +}