r179688 - DR974: Lambdas can have default arguments.
Matt Beaumont-Gay
matthewbg at google.com
Wed Apr 17 11:07:34 PDT 2013
On Wed, Apr 17, 2013 at 9:25 AM, Richard Smith
<richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Wed Apr 17 11:25:20 2013
> New Revision: 179688
>
> URL: http://llvm.org/viewvc/llvm-project?rev=179688&view=rev
> Log:
> DR974: Lambdas can have default arguments.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=179688&r1=179687&r2=179688&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Apr 17 11:25:20 2013
> @@ -254,7 +254,6 @@ def : DiagGroup<"strict-overflow=5">;
> def : DiagGroup<"strict-overflow">;
>
> def InvalidOffsetof : DiagGroup<"invalid-offsetof">;
> -def LambdaExtensions : DiagGroup<"lambda-extensions">;
> def : DiagGroup<"strict-prototypes">;
> def StrictSelector : DiagGroup<"strict-selector-match">;
> def MethodDuplicate : DiagGroup<"duplicate-method-match">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=179688&r1=179687&r2=179688&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 17 11:25:20 2013
> @@ -4789,9 +4789,6 @@ let CategoryName = "Lambda Issue" in {
> "incomplete result type %0 in lambda expression">;
> def err_lambda_objc_object_result : Error<
> "non-pointer Objective-C class type %0 in lambda expression result">;
> - def ext_lambda_default_arguments : ExtWarn<
> - "C++11 forbids default arguments for lambda expressions">,
> - InGroup<LambdaExtensions>;
> def err_noreturn_lambda_has_return_expr : Error<
> "lambda declared 'noreturn' should not return">;
> def warn_maybe_falloff_nonvoid_lambda : Warning<
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=179688&r1=179687&r2=179688&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr 17 11:25:20 2013
> @@ -636,22 +636,12 @@ void Sema::CheckCXXDefaultArguments(Func
> bool IsLambda = FD->getOverloadedOperator() == OO_Call &&
> isa<CXXMethodDecl>(FD) &&
> cast<CXXMethodDecl>(FD)->getParent()->isLambda();
> -
> +
> // Find first parameter with a default argument
> for (p = 0; p < NumParams; ++p) {
> ParmVarDecl *Param = FD->getParamDecl(p);
> - if (Param->hasDefaultArg()) {
> - // C++11 [expr.prim.lambda]p5:
> - // [...] Default arguments (8.3.6) shall not be specified in the
> - // parameter-declaration-clause of a lambda-declarator.
> - //
> - // FIXME: Core issue 974 strikes this sentence, we only provide an
> - // extension warning.
> - if (IsLambda)
IsLambda is now unused.
> - Diag(Param->getLocation(), diag::ext_lambda_default_arguments)
> - << Param->getDefaultArgRange();
> + if (Param->hasDefaultArg())
> break;
> - }
> }
>
> // C++ [dcl.fct.default]p4:
>
> Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp?rev=179688&r1=179687&r2=179688&view=diff
> ==============================================================================
> --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp (original)
> +++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp Wed Apr 17 11:25:20 2013
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -Wno-lambda-extensions -verify
> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
>
> void defargs() {
> auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
>
> Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp?rev=179688&r1=179687&r2=179688&view=diff
> ==============================================================================
> --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp (original)
> +++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp Wed Apr 17 11:25:20 2013
> @@ -39,12 +39,10 @@ void test_quals() {
> bogus_override_if_virtual<decltype(l)> bogus;
> }
>
> -// Default arguments (8.3.6) shall not be specified in the
> -// parameter-declaration-clause of a lambda- declarator.
> -// Note: Removed by core issue 974.
> +// Core issue 974: default arguments (8.3.6) may be specified in the
> +// parameter-declaration-clause of a lambda-declarator.
> int test_default_args() {
> - return [](int i = 5, // expected-warning{{C++11 forbids default arguments for lambda expressions}}
> - int j = 17) { return i+j;}(5, 6);
> + return [](int i = 5, int j = 17) { return i+j;}(5, 6);
> }
>
> // Any exception-specification specified on a lambda-expression
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list