* [C++ Patch] PR 84618 ("[8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460")
@ 2018-03-05 1:55 Paolo Carlini
2018-03-05 14:14 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2018-03-05 1:55 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
Hi,
a rather simple ice on invalid (not sure why only P4 given that no
meaningful diagnostic is emitted before ICEing). What happens is that
the ill-formed capture naming b, an OVERLOAD, escapes the early check in
cp_parser_lambda_introducer to eventually trigger a recently added
gcc_assert in build_capture_proxy. Adjusting the check means we also
provide slightly clearer (IMO, matching clang, anyway) error messages
for two testcases we already have.
Tested x86_64-linux.
Thanks, Paolo.
///////////////////////////////////////
[-- Attachment #2: CL_84618 --]
[-- Type: text/plain, Size: 398 bytes --]
/cp
2018-03-05 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
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.
[-- Attachment #3: patch_84618 --]
[-- Type: text/plain, Size: 2347 bytes --]
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 258235)
+++ cp/parser.c (working copy)
@@ -10377,15 +10377,15 @@ cp_parser_lambda_introducer (cp_parser* parser, tr
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)
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (revision 258235)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C (working copy)
@@ -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);
};
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C (revision 258235)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice23.C (working copy)
@@ -3,7 +3,7 @@
template <typename T>
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;
}
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C (nonexistent)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice29.C (working copy)
@@ -0,0 +1,8 @@
+// PR c++/84618
+// { dg-do compile { target c++11 } }
+
+template <int>
+struct S {
+ void b() const;
+ void b() { [b] {}; } // { dg-error "15:capture of non-variable" }
+};
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ Patch] PR 84618 ("[8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460")
2018-03-05 1:55 [C++ Patch] PR 84618 ("[8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460") Paolo Carlini
@ 2018-03-05 14:14 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-03-05 14:14 UTC (permalink / raw)
To: Paolo Carlini; +Cc: gcc-patches
OK.
On Sun, Mar 4, 2018 at 8:55 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> a rather simple ice on invalid (not sure why only P4 given that no
> meaningful diagnostic is emitted before ICEing). What happens is that the
> ill-formed capture naming b, an OVERLOAD, escapes the early check in
> cp_parser_lambda_introducer to eventually trigger a recently added
> gcc_assert in build_capture_proxy. Adjusting the check means we also provide
> slightly clearer (IMO, matching clang, anyway) error messages for two
> testcases we already have.
>
> Tested x86_64-linux.
>
> Thanks, Paolo.
>
> ///////////////////////////////////////
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-05 14:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 1:55 [C++ Patch] PR 84618 ("[8 Regression] ICE in build_capture_proxy, at cp/lambda.c:460") Paolo Carlini
2018-03-05 14:14 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).