Tested on Linux-x64. /cp 2014-09-14 Ville Voutilainen <ville.voutilai...@gmail.com>
Do not diagnose lambda default arguments in c++14 modes. * parser.c (cp_parser_lambda_declarator_opt): Make the pedwarn conditional. /testsuite 2014-09-14 Ville Voutilainen <ville.voutilai...@gmail.com> Do not diagnose lambda default arguments in c++14 modes. * g++.dg/cpp0x/lambda/lambda-defarg.C: Enable in c++11_only. * g++.dg/cpp1y/lambda-defarg.C: New.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c696fd2..de61eb9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9220,7 +9220,7 @@ 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)) + if (TREE_PURPOSE (t) && cxx_dialect < cxx14) pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic, "default argument specified for lambda parameter"); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C index cefa24d..11d8170 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C @@ -1,6 +1,6 @@ -// { dg-do compile { target c++11 } } +// { dg-do compile { target c++11_only } } int main() { - [](int a = 1) { return a; }(); // { dg-error "" } + [](int a = 1) { return a; }(); // { dg-error "default argument" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-defarg.C b/gcc/testsuite/g++.dg/cpp1y/lambda-defarg.C new file mode 100644 index 0000000..eafbe18 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-defarg.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } + +int main() +{ + [](int a = 1) { return a; }(); +}
lambda-defarg-cxx14.changelog
Description: Binary data