From: Paolo Carlini Date: Wed, 26 Jul 2017 21:46:22 +0000 (+0000) Subject: re PR c++/71570 (ICE on invalid variable capture in cxx_incomplete_type_diagnostic... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb08656284916b5bc6b4bfcd5561aa17bdc5ebeb;p=gcc.git re PR c++/71570 (ICE on invalid variable capture in cxx_incomplete_type_diagnostic, at cp/typeck2.c:55) /cp 2017-07-26 Paolo Carlini PR c++/71570 * lambda.c (add_capture): Early return if we cannot capture by reference. /testsuite 2017-07-26 Paolo Carlini PR c++/71570 * g++.dg/cpp0x/lambda/lambda-ice17.C: New. From-SVN: r250591 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9e763ae6d62..bf3d249c0ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-07-26 Paolo Carlini + + PR c++/71570 + * lambda.c (add_capture): Early return if we cannot capture by + reference. + 2017-07-26 Jason Merrill P0702R1 - List deduction of vector. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 0e02375fa1b..14ff6c2ae43 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -529,7 +529,10 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, 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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61d174388a5..39af41e5aa2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-26 Paolo Carlini + + PR c++/71570 + * g++.dg/cpp0x/lambda/lambda-ice17.C: New. + 2017-07-26 H.J. Lu PR target/81563 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C new file mode 100644 index 00000000000..57111fdef6a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C @@ -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); + }; +}