* [C++ PATCH] Fix ICE during C++11 lambda error recovery (PR c++/77791)
@ 2016-10-03 17:32 Jakub Jelinek
2016-10-04 15:26 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2016-10-03 17:32 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
In param_list some entries could be error_mark_node, we should just ignore
those. ALso, this patch optimizes by testing cxx_dialect < cxx14 just once.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2016-10-03 Jakub Jelinek <jakub@redhat.com>
PR c++/77791
* parser.c (cp_parser_lambda_declarator_opt): Only pedwarn
for C++11 on decls in the param_list. Test cxx_dialect < cxx14 before
the loop just once.
* g++.dg/cpp0x/lambda/lambda-77791.C: New test.
--- gcc/cp/parser.c.jj 2016-09-27 21:09:59.000000000 +0200
+++ gcc/cp/parser.c 2016-10-03 15:00:31.759317804 +0200
@@ -10114,10 +10114,11 @@ cp_parser_lambda_declarator_opt (cp_pars
/* Default arguments shall not be specified in the
parameter-declaration-clause of a lambda-declarator. */
- for (tree t = param_list; t; t = TREE_CHAIN (t))
- if (TREE_PURPOSE (t) && cxx_dialect < cxx14)
- pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
- "default argument specified for lambda parameter");
+ if (cxx_dialect < cxx14)
+ for (tree t = param_list; t; t = TREE_CHAIN (t))
+ if (TREE_PURPOSE (t) && DECL_P (TREE_VALUE (t)))
+ pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
+ "default argument specified for lambda parameter");
cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
--- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C.jj 2016-10-03 15:01:21.831694292 +0200
+++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C 2016-10-03 14:58:22.000000000 +0200
@@ -0,0 +1,4 @@
+// PR c++/77791
+// { dg-do compile { target c++11 } }
+
+auto a = [] (int i, int i = 0) {}; // { dg-error "redefinition of" }
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix ICE during C++11 lambda error recovery (PR c++/77791)
2016-10-03 17:32 [C++ PATCH] Fix ICE during C++11 lambda error recovery (PR c++/77791) Jakub Jelinek
@ 2016-10-04 15:26 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2016-10-04 15:26 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
OK.
On Mon, Oct 3, 2016 at 1:32 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> In param_list some entries could be error_mark_node, we should just ignore
> those. ALso, this patch optimizes by testing cxx_dialect < cxx14 just once.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-10-03 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/77791
> * parser.c (cp_parser_lambda_declarator_opt): Only pedwarn
> for C++11 on decls in the param_list. Test cxx_dialect < cxx14 before
> the loop just once.
>
> * g++.dg/cpp0x/lambda/lambda-77791.C: New test.
>
> --- gcc/cp/parser.c.jj 2016-09-27 21:09:59.000000000 +0200
> +++ gcc/cp/parser.c 2016-10-03 15:00:31.759317804 +0200
> @@ -10114,10 +10114,11 @@ cp_parser_lambda_declarator_opt (cp_pars
>
> /* Default arguments shall not be specified in the
> parameter-declaration-clause of a lambda-declarator. */
> - for (tree t = param_list; t; t = TREE_CHAIN (t))
> - if (TREE_PURPOSE (t) && cxx_dialect < cxx14)
> - pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
> - "default argument specified for lambda parameter");
> + if (cxx_dialect < cxx14)
> + for (tree t = param_list; t; t = TREE_CHAIN (t))
> + if (TREE_PURPOSE (t) && DECL_P (TREE_VALUE (t)))
> + pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
> + "default argument specified for lambda parameter");
>
> cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
>
> --- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C.jj 2016-10-03 15:01:21.831694292 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C 2016-10-03 14:58:22.000000000 +0200
> @@ -0,0 +1,4 @@
> +// PR c++/77791
> +// { dg-do compile { target c++11 } }
> +
> +auto a = [] (int i, int i = 0) {}; // { dg-error "redefinition of" }
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-04 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-03 17:32 [C++ PATCH] Fix ICE during C++11 lambda error recovery (PR c++/77791) Jakub Jelinek
2016-10-04 15:26 ` 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).