[cfe-commits] r149517 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp

Douglas Gregor dgregor at apple.com
Wed Feb 1 14:26:55 PST 2012


On Feb 1, 2012, at 2:25 PM, Richard Smith wrote:

> On Wed, Feb 1, 2012 at 9:18 AM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Wed Feb  1 11:18:19 2012
> New Revision: 149517
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=149517&view=rev
> Log:
> Diagnose the restriction on default arguments in C++11 [expr.prim.lambda]p5.
> 
> This restriction was removed by DR974.

We'll implement that post-C++11 tweak once more of lambdas are working. It *should* be as simple as dropping the error, but we'll see.

	- Doug


> Added:
>    cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp   (with props)
> Modified:
>    cfe/trunk/lib/Sema/SemaExprCXX.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=149517&r1=149516&r2=149517&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Feb  1 11:18:19 2012
> @@ -4886,9 +4886,15 @@
>     // C++11 [expr.prim.lambda]p5:
>     //   This function call operator is declared const (9.3.1) if and only if
>     //   the lambda-expression’s parameter-declaration-clause is not followed
> -    //   by mutable. It is neither virtual nor declared volatile.
> +    //   by mutable. It is neither virtual nor declared volatile. [...]
>     if (!FTI.hasMutableQualifier())
>       FTI.TypeQuals |= DeclSpec::TQ_const;
> +
> +    // C++11 [expr.prim.lambda]p5:
> +    //   [...] Default arguments (8.3.6) shall not be specified in the
> +    //   parameter-declaration-clause of a lambda-declarator.
> +    CheckExtraCXXDefaultArguments(ParamInfo);
> +
>     MethodTyInfo = GetTypeForDeclarator(ParamInfo, CurScope);
>     // FIXME: Can these asserts actually fail?
>     assert(MethodTyInfo && "no type from lambda-declarator");
> 
> Added: 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=149517&view=auto
> ==============================================================================
> --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp (added)
> +++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp Wed Feb  1 11:18:19 2012
> @@ -0,0 +1,7 @@
> +// RUN: %clang_cc1 -std=c++11 %s -verify
> +
> +int test_default_args() {
> +  [](int i = 5,  // expected-error{{default arguments can only be specified for parameters in a function declaration}} \
> +                 // expected-error{{lambda expressions are not supported yet}}
> +     int j = 17) {}; // expected-error{{default arguments can only be specified for parameters in a function declaration}}
> +}
> 
> Propchange: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
> ------------------------------------------------------------------------------
>    svn:eol-style = native
> 
> Propchange: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
> ------------------------------------------------------------------------------
>    svn:keywords = Id
> 
> Propchange: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
> ------------------------------------------------------------------------------
>    svn:mime-type = text/plain
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120201/e8594c69/attachment.html>


More information about the cfe-commits mailing list