This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++14 PATCH] Do not diagnose lambda default arguments in c++14 modes.


On 15 September 2014 18:51, Jason Merrill <jason@redhat.com> wrote:
> On 09/14/2014 10:55 AM, Ville Voutilainen wrote:
>>
>>      * g++.dg/cpp0x/lambda/lambda-defarg.C: Enable in c++11_only.
>>      * g++.dg/cpp1y/lambda-defarg.C: New.
>
>
> Instead of adding a second test, make only the dg-error c++11_only.


Ok.

/cp
2014-09-15  Ville Voutilainen  <ville.voutilainen@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-15  Ville Voutilainen  <ville.voutilainen@gmail.com>

        Do not diagnose lambda default arguments in c++14 modes.
        * g++.dg/cpp0x/lambda/lambda-defarg.C: dg-error in c++11_only.
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..7f69ea1 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C
@@ -2,5 +2,5 @@
 
 int main()
 {
-  [](int a = 1) { return a; }(); // { dg-error "" }
+  [](int a = 1) { return a; }(); // { dg-error "default argument" "" { target { c++11_only } } }
 }

Attachment: lambda-defarg-cxx14.changelog
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]