diff options
Diffstat (limited to 'test/CXX/expr/expr.prim/expr.prim.lambda')
6 files changed, 185 insertions, 189 deletions
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm index 0db2bf5..96e8fcd 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fblocks %s -verify +// RUN: %clang_cc1 -triple i686-pc-linux -std=c++11 -fblocks %s -verify void block_capture_errors() { __block int var; // expected-note 2{{'var' declared here}} @@ -85,6 +85,24 @@ namespace overloading { void call_with_lambda() { int &ir = accept_lambda_conv([](int x) { return x + 1; }); } + + template<typename T> using id = T; + + auto a = [](){}; + struct C : decltype(a) { + using decltype(a)::operator id<void(*)()>; + private: + using decltype(a)::operator id<void(^)()>; + } extern c; + + struct D : decltype(a) { + using decltype(a)::operator id<void(^)()>; + private: + using decltype(a)::operator id<void(*)()>; // expected-note {{here}} + } extern d; + + bool r1 = c; + bool r2 = d; // expected-error {{private}} } namespace PR13117 { diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp deleted file mode 100644 index 7f42c39..0000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -//expected-no-diagnostics -namespace lambda_capturing { -// FIXME: Once return type deduction is implemented for generic lambdas -// this will need to be updated. -void test() { - int i = 10; - { - auto L = [=](auto a) -> int { - return i + a; - }; - L(3); - } - { - auto L = [i](auto a) -> int { - return i + a; - }; - L(3); - } - { - auto L = [i=i](auto a) -> int { - return i + a; - }; - L(3); - } - - -} - -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp index 2ddcf18..551c100 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp @@ -100,3 +100,12 @@ namespace rdar14468891 { [x]() {}(); // expected-error{{by-copy capture of value of abstract type 'rdar14468891::X'}} } } + +namespace rdar15560464 { + struct X; // expected-note{{forward declaration of 'rdar15560464::X'}} + void foo(const X& param) { + auto x = ([=]() { + auto& y = param; // expected-error{{by-copy capture of variable 'param' with incomplete type 'const rdar15560464::X'}} + }); + } +} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp index 8a6e792..35b7789 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp @@ -10,7 +10,7 @@ void test_special_member_functions(MoveOnly mo, int i) { auto lambda1 = [i]() { }; // expected-note 2 {{lambda expression begins here}} // Default constructor - decltype(lambda1) lambda2; // expected-error{{call to implicitly-deleted default constructor of 'decltype(lambda1)' (aka '<lambda}} + decltype(lambda1) lambda2; // expected-error{{call to implicitly-deleted default constructor of 'decltype(lambda1)' (aka '(lambda}} // Copy assignment operator lambda1 = lambda1; // expected-error{{copy assignment operator is implicitly deleted}} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp index d41c450..03147a6 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp @@ -1,25 +1,25 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y
-
-// prvalue
-void prvalue() {
- auto&& x = [](auto a)->void { };
- auto& y = [](auto *a)->void { }; // expected-error{{cannot bind to a temporary of type}}
-}
-
-namespace std {
- class type_info;
-}
-
-struct P {
- virtual ~P();
-};
-
-void unevaluated_operand(P &p, int i) { //expected-note{{declared here}}
- // FIXME: this should only emit one error.
- int i2 = sizeof([](auto a, auto b)->void{}(3, '4')); // expected-error{{lambda expression in an unevaluated operand}} \
- // expected-error{{invalid application of 'sizeof'}}
- const std::type_info &ti1 = typeid([](auto &a) -> P& { static P p; return p; }(i));
- const std::type_info &ti2 = typeid([](auto) -> int { return i; }(i)); // expected-error{{lambda expression in an unevaluated operand}}\
- // expected-error{{cannot be implicitly captured}}\
- // expected-note{{begins here}}
-}
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y + +// prvalue +void prvalue() { + auto&& x = [](auto a)->void { }; + auto& y = [](auto *a)->void { }; // expected-error{{cannot bind to a temporary of type}} +} + +namespace std { + class type_info; +} + +struct P { + virtual ~P(); +}; + +void unevaluated_operand(P &p, int i) { //expected-note{{declared here}} + // FIXME: this should only emit one error. + int i2 = sizeof([](auto a, auto b)->void{}(3, '4')); // expected-error{{lambda expression in an unevaluated operand}} \ + // expected-error{{invalid application of 'sizeof'}} + const std::type_info &ti1 = typeid([](auto &a) -> P& { static P p; return p; }(i)); + const std::type_info &ti2 = typeid([](auto) -> int { return i; }(i)); // expected-error{{lambda expression in an unevaluated operand}}\ + // expected-error{{cannot be implicitly captured}}\ + // expected-note{{begins here}} +} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp index c5d3bf6..415c3d8 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp @@ -1,131 +1,131 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y
-
-namespace test_factorial {
-
-auto Fact = [](auto Self, unsigned n) -> unsigned {
- return !n ? 1 : Self(Self, n - 1) * n;
-};
-
-auto six = Fact(Fact, 3);
-
-}
-
-namespace overload_generic_lambda {
- template <class F1, class F2> struct overload : F1, F2 {
- using F1::operator();
- using F2::operator();
- overload(F1 f1, F2 f2) : F1(f1), F2(f2) { }
- };
-
- auto NumParams = [](auto Self, auto h, auto ... rest) -> unsigned {
- return 1 + Self(Self, rest...);
- };
- auto Base = [](auto Self, auto h) -> unsigned {
- return 1;
- };
- overload<decltype(Base), decltype(NumParams)> O(Base, NumParams);
- int num_params = O(O, 5, 3, "abc", 3.14, 'a');
-}
-
-
-namespace overload_generic_lambda_return_type_deduction {
- template <class F1, class F2> struct overload : F1, F2 {
- using F1::operator();
- using F2::operator();
- overload(F1 f1, F2 f2) : F1(f1), F2(f2) { }
- };
-
- auto NumParams = [](auto Self, auto h, auto ... rest) {
- return 1 + Self(Self, rest...);
- };
- auto Base = [](auto Self, auto h) {
- return 1;
- };
- overload<decltype(Base), decltype(NumParams)> O(Base, NumParams);
- int num_params = O(O, 5, 3, "abc", 3.14, 'a');
-}
-
-namespace test_standard_p5 {
-// FIXME: This test should eventually compile without an explicit trailing return type
-auto glambda = [](auto a, auto&& b) ->bool { return a < b; };
-bool b = glambda(3, 3.14); // OK
-
-}
-namespace test_deduction_failure {
- int test() {
- auto g = [](auto *a) { //expected-note{{candidate template ignored}}
- return a;
- };
- struct X { };
- X *x;
- g(x);
- g(3); //expected-error{{no matching function}}
- return 0;
- }
-
-}
-
-namespace test_instantiation_or_sfinae_failure {
-int test2() {
- {
- auto L = [](auto *a) {
- return (*a)(a); }; //expected-error{{called object type 'double' is not a function}}
- double d;
- L(&d); //expected-note{{in instantiation of}}
- auto M = [](auto b) { return b; };
- L(&M); // ok
- }
- {
- auto L = [](auto *a) ->decltype (a->foo()) { //expected-note2{{candidate template ignored:}}
- return (*a)(a); };
- double d;
- L(&d); //expected-error{{no matching function for call}}
- auto M = [](auto b) { return b; };
- L(&M); //expected-error{{no matching function for call}}
-
- }
- return 0;
-}
-
-
-}
-
-namespace test_misc {
-auto GL = [](auto a, decltype(a) b) //expected-note{{candidate function}}
- -> int { return a + b; };
-
-void test() {
- struct X { };
- GL(3, X{}); //expected-error{{no matching function}}
-}
-
-void test2() {
- auto l = [](auto *a) -> int {
- (*a)(a); return 0; }; //expected-error{{called object type 'double' is not a function}}
- l(&l);
- double d;
- l(&d); //expected-note{{in instantiation of}}
-}
-
-}
-
-namespace nested_lambdas {
- int test() {
- auto L = [](auto a) {
- return [=](auto b) {
- return a + b;
- };
- };
- }
- auto get_lambda() {
- return [](auto a) {
- return a;
- };
- };
-
- int test2() {
- auto L = get_lambda();
- L(3);
- }
-}
-
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y + +namespace test_factorial { + +auto Fact = [](auto Self, unsigned n) -> unsigned { + return !n ? 1 : Self(Self, n - 1) * n; +}; + +auto six = Fact(Fact, 3); + +} + +namespace overload_generic_lambda { + template <class F1, class F2> struct overload : F1, F2 { + using F1::operator(); + using F2::operator(); + overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } + }; + + auto NumParams = [](auto Self, auto h, auto ... rest) -> unsigned { + return 1 + Self(Self, rest...); + }; + auto Base = [](auto Self, auto h) -> unsigned { + return 1; + }; + overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); + int num_params = O(O, 5, 3, "abc", 3.14, 'a'); +} + + +namespace overload_generic_lambda_return_type_deduction { + template <class F1, class F2> struct overload : F1, F2 { + using F1::operator(); + using F2::operator(); + overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } + }; + + auto NumParams = [](auto Self, auto h, auto ... rest) { + return 1 + Self(Self, rest...); + }; + auto Base = [](auto Self, auto h) { + return 1; + }; + overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); + int num_params = O(O, 5, 3, "abc", 3.14, 'a'); +} + +namespace test_standard_p5 { +// FIXME: This test should eventually compile without an explicit trailing return type +auto glambda = [](auto a, auto&& b) ->bool { return a < b; }; +bool b = glambda(3, 3.14); // OK + +} +namespace test_deduction_failure { + int test() { + auto g = [](auto *a) { //expected-note{{candidate template ignored}} + return a; + }; + struct X { }; + X *x; + g(x); + g(3); //expected-error{{no matching function}} + return 0; + } + +} + +namespace test_instantiation_or_sfinae_failure { +int test2() { + { + auto L = [](auto *a) { + return (*a)(a); }; //expected-error{{called object type 'double' is not a function}} + double d; + L(&d); //expected-note{{in instantiation of}} + auto M = [](auto b) { return b; }; + L(&M); // ok + } + { + auto L = [](auto *a) ->decltype (a->foo()) { //expected-note2{{candidate template ignored:}} + return (*a)(a); }; + double d; + L(&d); //expected-error{{no matching function for call}} + auto M = [](auto b) { return b; }; + L(&M); //expected-error{{no matching function for call}} + + } + return 0; +} + + +} + +namespace test_misc { +auto GL = [](auto a, decltype(a) b) //expected-note{{candidate function}} + -> int { return a + b; }; + +void test() { + struct X { }; + GL(3, X{}); //expected-error{{no matching function}} +} + +void test2() { + auto l = [](auto *a) -> int { + (*a)(a); return 0; }; //expected-error{{called object type 'double' is not a function}} + l(&l); + double d; + l(&d); //expected-note{{in instantiation of}} +} + +} + +namespace nested_lambdas { + int test() { + auto L = [](auto a) { + return [=](auto b) { + return a + b; + }; + }; + } + auto get_lambda() { + return [](auto a) { + return a; + }; + }; + + int test2() { + auto L = get_lambda(); + L(3); + } +} + |