From: Paolo Carlini Date: Mon, 5 Mar 2018 15:40:15 +0000 (+0000) Subject: re PR c++/84618 (ICE in build_capture_proxy, at cp/lambda.c:460) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5625e74790579b589106e717dba7820933e541f1;p=gcc.git re PR c++/84618 (ICE in build_capture_proxy, at cp/lambda.c:460) /cp 2018-03-05 Paolo Carlini PR c++/84618 * parser.c (cp_parser_lambda_introducer): Reject any capture not involving a VAR_DECL or a PARM_DECL. /testsuite 2018-03-05 Paolo Carlini PR c++/84618 * g++.dg/cpp0x/lambda/lambda-ice29.C: New. * g++.dg/cpp0x/lambda/lambda-ice17.C: Adjust. * g++.dg/cpp0x/lambda/lambda-ice23.C: Likewise. From-SVN: r258250 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e9b0e3bd28e..5e166350e40 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-05 Paolo Carlini + + PR c++/84618 + * parser.c (cp_parser_lambda_introducer): Reject any capture not + involving a VAR_DECL or a PARM_DECL. + 2018-03-05 Pádraig Brady Jason Merrill Nathan Sidwell diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e1acb07d29e..460b5eaf10e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10377,15 +10377,15 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) unqualified_name_lookup_error (capture_id); continue; } - else if (DECL_P (capture_init_expr) - && (!VAR_P (capture_init_expr) - && TREE_CODE (capture_init_expr) != PARM_DECL)) + else if (!VAR_P (capture_init_expr) + && TREE_CODE (capture_init_expr) != PARM_DECL) { error_at (capture_token->location, - "capture of non-variable %qD ", + "capture of non-variable %qE ", capture_init_expr); - inform (DECL_SOURCE_LOCATION (capture_init_expr), - "%q#D declared here", capture_init_expr); + if (DECL_P (capture_init_expr)) + inform (DECL_SOURCE_LOCATION (capture_init_expr), + "%q#D declared here", capture_init_expr); continue; } if (VAR_P (capture_init_expr) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 569f040a6bf..44543c31f0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-03-05 Paolo Carlini + + PR c++/84618 + * g++.dg/cpp0x/lambda/lambda-ice29.C: New. + * g++.dg/cpp0x/lambda/lambda-ice17.C: Adjust. + * g++.dg/cpp0x/lambda/lambda-ice23.C: Likewise. + 2018-03-05 Olga Makhotina * g++.dg/other/i386-2.C: Add -mpconfig and -mwbnoinvd. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C index 57111fdef6a..8d84b64cfde 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C @@ -5,7 +5,7 @@ void foo (int); void foo (void) { - [&foo] // { dg-error "cannot capture" } + [&foo] // { dg-error "5:capture of non-variable" } { foo (0); }; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C index b811ad2da59..4fd2db63967 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C @@ -3,7 +3,7 @@ template constexpr int r(T x) { - auto f = [r,x]() { return r(x); }; // { dg-error "incomplete type" } + auto f = [r,x]() { return r(x); }; // { dg-error "13:capture of non-variable" } return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C new file mode 100644 index 00000000000..80f5b38b83a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C @@ -0,0 +1,8 @@ +// PR c++/84618 +// { dg-do compile { target c++11 } } + +template +struct S { + void b() const; + void b() { [b] {}; } // { dg-error "15:capture of non-variable" } +};