From f72da967576271070086b2252a8463bb69f93abd Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 4 Oct 2016 17:34:16 +0200 Subject: [PATCH] =?utf8?q?re=20PR=20c++/77791=20(ICE=20on=20invalid=20C++1?= =?utf8?q?1=20code=20with=20redefined=20function=20parameter:=20tree=20che?= =?utf8?q?ck:=20expected=20tree=20that=20contains=20=E2=80=98decl=20minima?= =?utf8?q?l=E2=80=99=20structure,=20have=20=E2=80=98error=5Fmark=E2=80=99?= =?utf8?q?=20in=20cp=5Fparser=5Flambda=5Fdeclarator=5Fopt,=20at=20cp/parse?= =?utf8?q?r.c:1011)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. From-SVN: r240751 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 9 +++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 48edc6e03ef..637aed4a00b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-10-04 Jakub Jelinek + 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. + * cp-tree.h (enum cp_tree_index): Remove CPTI_JAVA_*, CPTI_LANG_NAME_JAVA and CPTI_JCLASS. (java_byte_type_node, java_short_type_node, java_int_type_node, diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 16b895cf37a..8581375655c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10114,10 +10114,11 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) /* 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef45ca1ca3b..3b2e14a9c9c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-10-04 Jakub Jelinek + PR c++/77791 + * g++.dg/cpp0x/lambda/lambda-77791.C: New test. + * g++.dg/other/java3.C: Remove. * g++.dg/other/java1.C: Remove. * g++.dg/other/error12.C: Remove. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C new file mode 100644 index 00000000000..0475d278688 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C @@ -0,0 +1,4 @@ +// PR c++/77791 +// { dg-do compile { target c++11 } } + +auto a = [] (int i, int i = 0) {}; // { dg-error "redefinition of" } -- 2.30.2