diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-01-07 01:08:17 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-01-07 01:08:17 +0000 |
commit | e81d7e9810eed0d805263791d761ec545d2cf779 (patch) | |
tree | a48a534d55c3e1430f8475c8b9219d1052c6d669 /test/SemaCXX/lambda-expressions.cpp | |
parent | 3070e13dca5bbefa32acb80ce4a7b217a6220983 (diff) |
Lambdas: semantic analysis of explicit captures.
This patch (and some of my other commits related to lambdas) is heavily based off of John Freeman's work-in-progress patches.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147706 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/lambda-expressions.cpp')
-rw-r--r-- | test/SemaCXX/lambda-expressions.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp new file mode 100644 index 0000000000..50d0d6deb8 --- /dev/null +++ b/test/SemaCXX/lambda-expressions.cpp @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +namespace ExplicitCapture { + int GlobalVar; // expected-note {{declared here}} + + namespace N { + int AmbiguousVar; // expected-note {{candidate}} + } + int AmbiguousVar; // expected-note {{candidate}} + using namespace N; + + class C { + int x; + + void f(int); + void f() { + int foo; + + [foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}} + [this, this] () {}; // expected-error {{'this' can appear only once}} expected-error {{not supported yet}} + [=, foo] () {}; // expected-error {{'&' must precede a capture when}} expected-error {{not supported yet}} + [=, &foo] () {}; // expected-error {{not supported yet}} + [=, this] () {}; // expected-error {{'this' cannot appear}} expected-error {{not supported yet}} + [&, foo] () {}; // expected-error {{not supported yet}} + [&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} expected-error {{not supported yet}} + [&, this] () {}; // expected-error {{not supported yet}} + [&f] () {}; // expected-error {{does not name a variable}} expected-error {{not supported yet}} + [&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} expected-error {{not supported yet}} + [&AmbiguousVar] () {} // expected-error {{reference to 'AmbiguousVar' is ambiguous}} expected-error {{not supported yet}} + [&Globalvar] () {}; // expected-error {{use of undeclared identifier 'Globalvar'; did you mean 'GlobalVar}} + } + }; + + void f() { + [this] () {}; // expected-error {{invalid use of 'this'}} expected-error {{not supported yet}} + } +} |