diff mbox

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

Message ID CAFk2RUbL9yVSNv4Nd2fMdg4hOzpn56cX7OA9dN7evgBPr8v00g@mail.gmail.com
State New
Headers show

Commit Message

Ville Voutilainen Sept. 14, 2014, 2:55 p.m. UTC
Tested on Linux-x64.

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

Comments

Jason Merrill Sept. 15, 2014, 3:51 p.m. UTC | #1
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.

Jason
diff mbox

Patch

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; }(); 
+}