summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/lambda-expressions.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-01-07 04:59:52 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-01-07 04:59:52 +0000
commit73a040906d0cbf2240ed2bf19523fc0d73651bf8 (patch)
tree198a38b41b513ab3d34691846ac4fd27a3c45d52 /clang/test/SemaCXX/lambda-expressions.cpp
parent11c99162c41f6c788b2535779915a70319dc3510 (diff)
downloadbcm5719-llvm-73a040906d0cbf2240ed2bf19523fc0d73651bf8.tar.gz
bcm5719-llvm-73a040906d0cbf2240ed2bf19523fc0d73651bf8.zip
More lambda work: semantic analysis of capturing 'this'. It's a bit complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.)
llvm-svn: 147723
Diffstat (limited to 'clang/test/SemaCXX/lambda-expressions.cpp')
-rw-r--r--clang/test/SemaCXX/lambda-expressions.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
index 50d0d6deb84..9411c34ec8d 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+namespace std { class type_info; };
+
namespace ExplicitCapture {
int GlobalVar; // expected-note {{declared here}}
@@ -10,10 +12,13 @@ namespace ExplicitCapture {
using namespace N;
class C {
- int x;
+ int Member;
+
+ static void Overload(int);
+ void Overload();
+ virtual C& Overload(float);
- void f(int);
- void f() {
+ void ExplicitCapture() {
int foo;
[foo, foo] () {}; // expected-error {{'foo' can appear only once}} expected-error {{not supported yet}}
@@ -24,11 +29,23 @@ namespace ExplicitCapture {
[&, 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}}
+ [&Overload] () {}; // 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 ImplicitThisCapture() {
+ [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
+ [&](){(void)Member;}; // expected-error {{not supported yet}}
+ [this](){(void)Member;}; // expected-error {{not supported yet}}
+ [this]{[this]{};};// expected-error 2 {{not supported yet}}
+ []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error 2 {{not supported yet}}
+ []{Overload(3);}; // expected-error {{not supported yet}}
+ []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
+ []{(void)typeid(Overload());};// expected-error {{not supported yet}}
+ []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} expected-error {{not supported yet}}
+ }
};
void f() {
OpenPOWER on IntegriCloud