diff options
author | Faisal Vali <faisalv@yahoo.com> | 2013-10-03 05:58:37 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2013-10-03 05:58:37 +0000 |
commit | 9683f1de5f8eb3a4dd7c7fcb4ff58033b9cfa46f (patch) | |
tree | 66cca89d5380deb7fba4de1bde3496cb0940744a /test/SemaCXX/cxx1y-generic-lambdas.cpp | |
parent | aecbb9de3bed4372695756f18af2c1304a81e7c4 (diff) | |
download | clang-9683f1de5f8eb3a4dd7c7fcb4ff58033b9cfa46f.tar.gz |
Revert changes from the nested lambdas commit till i figure out
why the buildbots are failing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191876 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx1y-generic-lambdas.cpp')
-rw-r--r-- | test/SemaCXX/cxx1y-generic-lambdas.cpp | 480 |
1 files changed, 3 insertions, 477 deletions
diff --git a/test/SemaCXX/cxx1y-generic-lambdas.cpp b/test/SemaCXX/cxx1y-generic-lambdas.cpp index c5da672f1d..b66825a536 100644 --- a/test/SemaCXX/cxx1y-generic-lambdas.cpp +++ b/test/SemaCXX/cxx1y-generic-lambdas.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm -o - %s +// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks %s // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING @@ -99,8 +99,10 @@ void test() { //expected-note{{candidate}} } } + } + namespace return_type_deduction_ok { auto l = [](auto a) ->auto { return a; }(2); auto l2 = [](auto a) ->decltype(auto) { return a; }(2); @@ -112,479 +114,3 @@ namespace generic_lambda_as_default_argument_ok { void test(int i = [](auto a)->int { return a; }(3)) { } } - -namespace nested_non_capturing_lambda_tests { -template<class ... Ts> void print(Ts ...) { } -int test() { -{ - auto L = [](auto a) { - return [](auto b) { - return b; - }; - }; - auto M = L(3); - M(4.15); - } -{ - int i = 10; //expected-note{{declared here}} - auto L = [](auto a) { - return [](auto b) { //expected-note{{begins here}} - i = b; //expected-error{{cannot be implicitly captured}} - return b; - }; - }; - auto M = L(3); - M(4.15); //expected-note{{instantiation}} - } - { - auto L = [](auto a) { - print("a = ", a, "\n"); - return [](auto b) ->decltype(a) { - print("b = ", b, "\n"); - return b; - }; - }; - auto M = L(3); - M(4.15); - } - -{ - auto L = [](auto a) ->decltype(a) { - print("a = ", a, "\n"); - return [](auto b) ->decltype(a) { //expected-error{{no viable conversion}}\ - //expected-note{{candidate template ignored}} - print("b = ", b, "\n"); - return b; - }; - }; - auto M = L(3); //expected-note{{in instantiation of}} - } -{ - auto L = [](auto a) { - print("a = ", a, "\n"); - return [](auto ... b) ->decltype(a) { - print("b = ", b ..., "\n"); - return 4; - }; - }; - auto M = L(3); - M(4.15, 3, "fv"); -} - -{ - auto L = [](auto a) { - print("a = ", a, "\n"); - return [](auto ... b) ->decltype(a) { - print("b = ", b ..., "\n"); - return 4; - }; - }; - auto M = L(3); - int (*fp)(double, int, const char*) = M; - fp(4.15, 3, "fv"); -} - -{ - auto L = [](auto a) { - print("a = ", a, "\n"); - return [](char b) { - return [](auto ... c) ->decltype(b) { - print("c = ", c ..., "\n"); - return 42; - }; - }; - }; - L(4); - auto M = L(3); - M('a'); - auto N = M('x'); - N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - char (*np)(const char*, int, const char*, double, const char*, int) = N; - np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -} - - -{ - auto L = [](auto a) { - print("a = ", a, "\n"); - return [](decltype(a) b) { - return [](auto ... c) ->decltype(b) { - print("c = ", c ..., "\n"); - return 42; - }; - }; - }; - L('4'); - auto M = L('3'); - M('a'); - auto N = M('x'); - N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - char (*np)(const char*, int, const char*, double, const char*, int) = N; - np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -} - - -{ - struct X { - static void foo(double d) { } - void test() { - auto L = [](auto a) { - print("a = ", a, "\n"); - foo(a); - return [](decltype(a) b) { - foo(b); - foo(sizeof(a) + sizeof(b)); - return [](auto ... c) ->decltype(b) { - print("c = ", c ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return 42; - }; - }; - }; - L('4'); - auto M = L('3'); - M('a'); - auto N = M('x'); - N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - char (*np)(const char*, int, const char*, double, const char*, int) = N; - np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - } -}; -X x; -x.test(); -} -// Make sure we can escape the function -{ - struct X { - static void foo(double d) { } - auto test() { - auto L = [](auto a) { - print("a = ", a, "\n"); - foo(a); - return [](decltype(a) b) { - foo(b); - foo(sizeof(a) + sizeof(b)); - return [](auto ... c) ->decltype(b) { - print("c = ", c ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return 42; - }; - }; - }; - return L; - } -}; - X x; - auto L = x.test(); - L('4'); - auto M = L('3'); - M('a'); - auto N = M('x'); - N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - char (*np)(const char*, int, const char*, double, const char*, int) = N; - np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -} - -{ - struct X { - static void foo(double d) { } - auto test() { - auto L = [](auto a) { - print("a = ", a, "\n"); - foo(a); - return [](decltype(a) b) { - foo(b); - foo(sizeof(a) + sizeof(b)); - return [](auto ... c) { - print("c = ", c ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} - print("d = ", d ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return decltype(a){}; - }; - }; - }; - }; - return L; - } -}; - X x; - auto L = x.test(); - L('4'); - auto M = L('3'); - M('a'); - auto N = M('x'); - auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - char (*np)(const char*, int, const char*, double, const char*, int) = O; - np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); - int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} - -} -} // end test() - -namespace wrapped_within_templates { - -namespace explicit_return { -template<class T> int fooT(T t) { - auto L = [](auto a) -> void { - auto M = [](char b) -> void { - auto N = [](auto c) -> void { - int x = 0; - x = sizeof(a); - x = sizeof(b); - x = sizeof(c); - }; - N('a'); - N(decltype(a){}); - }; - }; - L(t); - L(3.14); - return 0; -} - -int run = fooT('a') + fooT(3.14); - -} // end explicit_return - -namespace implicit_return_deduction { -template<class T> auto fooT(T t) { - auto L = [](auto a) { - auto M = [](char b) { - auto N = [](auto c) { - int x = 0; - x = sizeof(a); - x = sizeof(b); - x = sizeof(c); - }; - N('a'); - N(decltype(a){}); - }; - }; - L(t); - L(3.14); - return 0; -} - -int run = fooT('a') + fooT(3.14); - -template<class ... Ts> void print(Ts ... ts) { } - -template<class F, class ... Rest> using first = F; - -template<class ... Ts> auto fooV(Ts ... ts) { - auto L = [](auto ... a) { - auto M = [](decltype(a) ... b) { - auto N = [](auto c) { - int x = 0; - x = sizeof...(a); - x = sizeof...(b); - x = sizeof(c); - }; - N('a'); - N(N); - N(first<Ts...>{}); - }; - M(a...); - print("a = ", a..., "\n"); - }; - L(L, ts...); - print("ts = ", ts..., "\n"); - return 0; -} - -int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); - -} //implicit_return_deduction - - -} //wrapped_within_templates - -namespace at_ns_scope { - void foo(double d) { } - auto test() { - auto L = [](auto a) { - print("a = ", a, "\n"); - foo(a); - return [](decltype(a) b) { - foo(b); - foo(sizeof(a) + sizeof(b)); - return [](auto ... c) { - print("c = ", c ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} - print("d = ", d ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return decltype(a){}; - }; - }; - }; - }; - return L; - } -auto L = test(); -auto L_test = L('4'); -auto M = L('3'); -auto M_test = M('a'); -auto N = M('x'); -auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -char (*np)(const char*, int, const char*, double, const char*, int) = O; -auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} - - - -} - -namespace variadic_tests_1 { -template<class ... Ts> void print(Ts ... ts) { } - -template<class F, class ... Rest> using FirstType = F; -template<class F, class ... Rest> F& FirstArg(F& f, Rest...) { return f; } - -template<class ... Ts> int fooV(Ts ... ts) { - auto L = [](auto ... a) -> void { - auto M = [](decltype(a) ... b) -> void { - auto N = [](auto c) -> void { - int x = 0; - x = sizeof...(a); - x = sizeof...(b); - x = sizeof(c); - }; - N('a'); - N(N); - N(FirstType<Ts...>{}); - }; - M(a...); - print("a = ", a..., "\n"); - }; - L(L, ts...); - print("ts = ", ts..., "\n"); - return 0; -} - -int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); - -namespace more_variadic_1 { - -template<class ... Ts> int fooV(Ts ... ts) { - auto L = [](auto ... a) { - auto M = [](decltype(a) ... b) -> void { - auto N = [](auto c) -> void { - int x = 0; - x = sizeof...(a); - x = sizeof...(b); - x = sizeof(c); - }; - N('a'); - N(N); - N(FirstType<Ts...>{}); - }; - M(a...); - return M; - }; - auto M = L(L, ts...); - decltype(L(L, ts...)) (*fp)(decltype(L), decltype(ts) ...) = L; - void (*fp2)(decltype(L), decltype(ts) ...) = L(L, ts...); - - { - auto L = [](auto ... a) { - auto M = [](decltype(a) ... b) { - auto N = [](auto c) -> void { - int x = 0; - x = sizeof...(a); - x = sizeof...(b); - x = sizeof(c); - }; - N('a'); - N(N); - N(FirstType<Ts...>{}); - return N; - }; - M(a...); - return M; - }; - auto M = L(L, ts...); - decltype(L(L, ts...)) (*fp)(decltype(L), decltype(ts) ...) = L; - fp(L, ts...); - decltype(L(L, ts...)(L, ts...)) (*fp2)(decltype(L), decltype(ts) ...) = L(L, ts...); - fp2 = fp(L, ts...); - void (*fp3)(char) = fp2(L, ts...); - fp3('a'); - } - return 0; -} - -int run2 = fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{}); - - -} //end ns more_variadic_1 - -} // end ns variadic_tests_1 - -namespace at_ns_scope_within_class_member { - struct X { - static void foo(double d) { } - auto test() { - auto L = [](auto a) { - print("a = ", a, "\n"); - foo(a); - return [](decltype(a) b) { - foo(b); - foo(sizeof(a) + sizeof(b)); - return [](auto ... c) { - print("c = ", c ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return [](decltype(c) ... d) ->decltype(a) { //expected-note{{candidate}} - print("d = ", d ..., "\n"); - foo(decltype(b){}); - foo(sizeof(decltype(a)*) + sizeof(decltype(b)*)); - return decltype(a){}; - }; - }; - }; - }; - return L; - } -}; -X x; -auto L = x.test(); -auto L_test = L('4'); -auto M = L('3'); -auto M_test = M('a'); -auto N = M('x'); -auto O = N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -char (*np)(const char*, int, const char*, double, const char*, int) = O; -auto NP_result = np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456); -int (*np2)(const char*, int, const char*, double, const char*, int) = O; // expected-error{{no viable conversion}} - -} //end at_ns_scope_within_class_member - - -namespace nested_generic_lambdas_123 { -void test() { - auto L = [](auto a) -> int { - auto M = [](auto b, decltype(a) b2) -> int { - return 1; - }; - M(a, a); - }; - L(3); -} -template<class T> void foo(T) { - auto L = [](auto a) { return a; }; -} -template void foo(int); -} // end ns nested_generic_lambdas_123 - - -} // end ns nested_non_capturing_lambda_tests -
\ No newline at end of file |