diff options
Diffstat (limited to 'clang/test/CXX')
6 files changed, 2 insertions, 342 deletions
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp deleted file mode 100644 index 29044f47455..00000000000 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -//FIXME: These tests were written when return type deduction had not been implemented -// for generic lambdas, hence -template<class T> T id(T t); -template<class ... Ts> int vfoo(Ts&& ... ts); -auto GL1 = [](auto a, int i) -> int { return id(a); }; - -auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; -auto GL3 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; - -auto GL4 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; - - -void foo() { - auto GL1 = [](auto a, int i) -> int { return id(a); }; - - auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; -} - - -int main() -{ - auto l1 = [](auto a) -> int { return a + 5; }; - auto l2 = [](auto *p) -> int { return p + 5; }; - - struct A { int i; char f(int) { return 'c'; } }; - auto l3 = [](auto &&ur, - auto &lr, - auto v, - int i, - auto* p, - auto A::*memvar, - auto (A::*memfun)(int), - char c, - decltype (v)* pv - , auto (&array)[5] - ) -> int { return v + i + c - + array[0]; - }; - int arr[5] = {0, 1, 2, 3, 4 }; - int lval = 0; - double d = 3.14; - l3(3, lval, d, lval, &lval, &A::i, &A::f, 'c', &d, arr); - auto l4 = [](decltype(auto) a) -> int { return 0; }; //expected-error{{decltype(auto)}} - { - struct Local { - static int ifi(int i) { return i; } - static char cfi(int) { return 'a'; } - static double dfi(int i) { return i + 3.14; } - static Local localfi(int) { return Local{}; } - }; - auto l4 = [](auto (*fp)(int)) -> int { return fp(3); }; //expected-error{{no viable conversion from 'Local' to 'int'}} - l4(&Local::ifi); - l4(&Local::cfi); - l4(&Local::dfi); - l4(&Local::localfi); //expected-note{{in instantiation of function template specialization}} - } - { - auto unnamed_parameter = [](auto, auto) -> void { }; - unnamed_parameter(3, '4'); - } - { - auto l = [](auto - (*)(auto)) { }; //expected-error{{'auto' not allowed}} - //FIXME: These diagnostics might need some work. - auto l2 = [](char auto::*pm) { }; //expected-error{{cannot combine with previous}}\ - expected-error{{'pm' does not point into a class}} - auto l3 = [](char (auto::*pmf)()) { }; //expected-error{{'auto' not allowed}}\ - expected-error{{'pmf' does not point into a class}}\ - expected-error{{function cannot return function type 'char ()'}} - } -} - - diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp deleted file mode 100644 index fcfd9bcb7d9..00000000000 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/generic-lambda-unimplemented-1y.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -emit-llvm -namespace return_type_deduction_ok { -// FIXME: Once return type deduction is implemented for generic lambdas -// this will need to be updated. - auto l = [](auto a) ->auto { return a; }(2); - auto l2 = [](auto a) ->decltype(auto) { return a; }(2); - auto l3 = [](auto a) { return a; }(2); - - -} - -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 { //expected-error{{unimplemented}} - return i + a; - }; - L(3); -} - -} - -namespace nested_generic_lambdas { -void test() { - auto L = [](auto a) -> int { - auto M = [](auto b, decltype(a) b2) -> int { //expected-error{{unimplemented}} - return 1; - }; - M(a, a); - }; - L(3); //expected-note{{in instantiation of}} -} -} - -namespace conversion_operator { -void test() { - auto L = [](auto a) -> int { return a; }; - int (*fp)(int) = L; //expected-error{{no viable conversion}} - } -} - -namespace generic_lambda_as_default_argument_ok { - void test(int i = [](auto a)->int { return a; }(3)) { - - } - -} - diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp deleted file mode 100644 index 44656a37e31..00000000000 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// 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) {
- // 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}}
-}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp index f8461335b76..79ee76f0258 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp @@ -7,60 +7,3 @@ int &d = [] (int &r) -> auto & { return r; } (a); int &e = [] (int &r) -> auto { return r; } (a); // expected-error {{cannot bind to a temporary}} int &f = [] (int r) -> decltype(auto) { return r; } (a); // expected-error {{cannot bind to a temporary}} int &g = [] (int r) -> decltype(auto) { return (r); } (a); // expected-warning {{reference to stack}} - - -int test_explicit_auto_return() -{ - struct X {}; - auto L = [](auto F, auto a) { return F(a); }; - auto M = [](auto a) -> auto { return a; }; // OK - auto MRef = [](auto b) -> auto& { return b; }; //expected-warning{{reference to stack}} - auto MPtr = [](auto c) -> auto* { return &c; }; //expected-warning{{address of stack}} - auto MDeclType = [](auto&& d) -> decltype(auto) { return static_cast<decltype(d)>(d); }; //OK - M(3); - - auto &&x = MDeclType(X{}); - auto &&x1 = M(X{}); - auto &&x2 = MRef(X{});//expected-note{{in instantiation of}} - auto &&x3 = MPtr(X{}); //expected-note{{in instantiation of}} - return 0; -} - -int test_implicit_auto_return() -{ - { - auto M = [](auto a) { return a; }; - struct X {}; - X x = M(X{}); - - } -} - -int test_multiple_returns() { - auto M = [](auto a) { - bool k; - if (k) - return a; - else - return 5; //expected-error{{deduced as 'int' here}} - }; - M(3); // OK - M('a'); //expected-note{{in instantiation of}} - return 0; -} -int test_no_parameter_list() -{ - static int si = 0; - auto M = [] { return 5; }; // OK - auto M2 = [] -> auto&& { return si; }; // expected-error{{lambda requires '()'}} - M(); -} - -int test_conditional_in_return() { - auto Fac = [](auto f, auto n) { - return n <= 0 ? n : f(f, n - 1) * n; - }; - // FIXME: this test causes a recursive limit - need to error more gracefully. - //Fac(Fac, 3); - -}
\ No newline at end of file diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp index 1016cb1d305..c69aa115beb 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -DCPP1Y +// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify void missing_lambda_declarator() { [](){}(); @@ -18,7 +18,7 @@ void infer_void_return_type(int i) { switch (x) { case 0: return get<void>(); case 1: return; - case 2: return { 1, 2.0 }; //expected-error{{cannot deduce}} + case 2: return { 1, 2.0 }; // expected-error{{cannot deduce lambda return type from initializer list}} } }(7); } diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp deleted file mode 100644 index c1311617efb..00000000000 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y -emit-llvm
-
-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}}
- //l(&l);
- 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); };
- //l(&l);
- 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) { //expected-error{{unimplemented}}
- return a + b;
- };
- };
- // auto M = L(3.14);
- // return M('4');
- }
- auto get_lambda() {
- return [](auto a) {
- return a;
- };
- };
-
- int test2() {
- auto L = get_lambda();
- L(3);
- }
-}
-
|

