From 6a3d8ef0b86f81b7eb72a29b3d5339f5062a8453 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Mon, 15 Sep 2014 22:31:35 +0300 Subject: [PATCH] Do not diagnose lambda default arguments in c++14 modes. * parser.c (cp_parser_lambda_declarator_opt): Make the pedwarn conditional. From-SVN: r215274 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 2 +- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fe312364ccc..7e1b0f9f78d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-15 Ville Voutilainen + + Do not diagnose lambda default arguments in c++14 modes. + * parser.c (cp_parser_lambda_declarator_opt): Make the pedwarn + conditional. + 2014-09-15 Jakub Jelinek * Make-lang.in (check_g++_parallelize): Change to just an upper bound diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a3c947a9a69..9764794c881 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9222,7 +9222,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 cefa24d434e..7f69ea13eef 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 } } } } -- 2.30.2