[cfe-commits] r157947 - in /cfe/trunk/test: CXX/expr/expr.prim/expr.prim.lambda/p4.cpp SemaCXX/lambda-expressions.cpp
Aaron Ballman
aaron at aaronballman.com
Mon Jun 4 13:07:46 PDT 2012
Author: aaronballman
Date: Mon Jun 4 15:07:46 2012
New Revision: 157947
URL: http://llvm.org/viewvc/llvm-project?rev=157947&view=rev
Log:
Fixes some test cases that should have come along with r157943.
Modified:
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp
Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp?rev=157947&r1=157946&r2=157947&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp Mon Jun 4 15:07:46 2012
@@ -25,7 +25,7 @@
struct X { };
X infer_X_return_type(X x) {
- return [&x](int y) { // expected-warning{{omitted result type}}
+ return [&x](int y) {
if (y > 0)
return X();
else
@@ -33,11 +33,11 @@
}(5);
}
-X infer_X_return_type_fail(X x) {
- return [x](int y) { // expected-warning{{omitted result type}}
+X infer_X_return_type_fail(X x) {
+ return [x](int y) {
if (y > 0)
return X();
- else
+ else
return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
}(5);
}
Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=157947&r1=157946&r2=157947&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Jun 4 15:07:46 2012
@@ -17,74 +17,71 @@
[this](){(void)Member;};
[this]{[this]{};};
[]{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
- []{Overload(3);};
- []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ []{Overload(3);};
+ []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
[]{(void)typeid(Overload());};
- []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+ []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
}
};
void f() {
- [this] () {}; // expected-error {{'this' cannot be captured in this context}}
+ [this] () {}; // expected-error {{'this' cannot be captured in this context}}
}
}
namespace ReturnDeduction {
void test() {
- [](){ return 1; };
- [](){ return 1; };
- [](){ return ({return 1; 1;}); };
- [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} \
- // expected-warning{{omitted result type}}
- []()->int{ return 'c'; return 1; };
+ [](){ return 1; };
+ [](){ return 1; };
+ [](){ return ({return 1; 1;}); };
+ [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}}
+ []()->int{ return 'c'; return 1; };
[](){ return 'c'; return 1; }; // expected-error {{must match previous return type}}
- []() { return; return (void)0; };
- [](){ return 1; return 1; }; // expected-warning{{omitted result type}}
+ []() { return; return (void)0; };
+ [](){ return 1; return 1; };
}
}
namespace ImplicitCapture {
void test() {
int a = 0; // expected-note 5 {{declared}}
- []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
- [&]() { return a; };
- [=]() { return a; };
- [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
+ []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+ [&]() { return a; };
+ [=]() { return a; };
+ [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
[=]() { return [&]() { return a; }; };
- []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
- []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
- []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}}
- [=]() { return [&a] { return a; }; }; //
+ []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}}
+ [=]() { return [&a] { return a; }; }; //
const int b = 2;
- []() { return b; };
+ []() { return b; };
union { // expected-note {{declared}}
int c;
float d;
};
d = 3;
- [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}}
+ [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}}
__block int e; // expected-note 3 {{declared}}
- [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}}
- [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}}
+ [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}}
+ [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}}
int f[10]; // expected-note {{declared}}
- [&]() { return f[2]; };
+ [&]() { return f[2]; };
(void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \
// expected-note{{lambda expression begins here}}
struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}}
G g;
- [=]() { const G* gg = &g; return gg->a; }; // expected-warning{{omitted result type}}
- [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} \
- // expected-warning{{omitted result type}}
- (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \
- // expected-warning{{omitted result type}}
+ [=]() { const G* gg = &g; return gg->a; };
+ [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}}
+ (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}}
const int h = a; // expected-note {{declared}}
- []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
// The exemption for variables which can appear in constant expressions
// applies only to objects (and not to references).
More information about the cfe-commits
mailing list