summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorFaisal Vali <faisalv@yahoo.com>2013-10-24 01:05:22 +0000
committerFaisal Vali <faisalv@yahoo.com>2013-10-24 01:05:22 +0000
commit66605d40a74aa26664050d41f900c37ad5fbbfe9 (patch)
treefaf220d6acd14aea3facf87a550ef24d320da423 /clang/test
parente0bc980500bfe3c0a2b5117bb77f9131e944c7ad (diff)
downloadbcm5719-llvm-66605d40a74aa26664050d41f900c37ad5fbbfe9.tar.gz
bcm5719-llvm-66605d40a74aa26664050d41f900c37ad5fbbfe9.zip
Fix an instantiation bug with nested generic lambdas and conversion to fptrs.
This patch fixes the typelocs of the conversion-operator and the conversion-operator-name and adds the parameters of the call operator to the FunctionProtoTypeLoc of the respective entities. Thus, when the template declarations (conversion operators) undergo deduction and instantiation/transformation/substitution - they add themselves to the local instantiation scope if needed. This patch supports the following: auto L = [](auto b) { return [](auto a) ->decltype(a) { return a; }; }; int (*fp)(int) = L(8); Richard LGTM'd this patch: http://llvm-reviews.chandlerc.com/D1831 Thanks! llvm-svn: 193294
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/cxx1y-generic-lambdas.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp b/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
index 64b9ff14215..34074417709 100644
--- a/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ b/clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -585,6 +585,50 @@ template<class T> void foo(T) {
template void foo(int);
} // end ns nested_generic_lambdas_123
+namespace nested_fptr_235 {
+int test()
+{
+ auto L = [](auto b) {
+ return [](auto a) ->decltype(a) { return a; };
+ };
+ int (*fp)(int) = L(8);
+ fp(5);
+ L(3);
+ char (*fc)(char) = L('a');
+ fc('b');
+ L('c');
+ double (*fd)(double) = L(3.14);
+ fd(3.14);
+ fd(6.26);
+ return 0;
+}
+int run = test();
+}
+
+
+namespace fptr_with_decltype_return_type {
+template<class F, class ... Ts> using FirstType = F;
+template<class F, class ... Rest> F& FirstArg(F& f, Rest& ... r) { return f; };
+template<class ... Ts> auto vfun(Ts&& ... ts) {
+ print(ts...);
+ return FirstArg(ts...);
+}
+int test()
+{
+ {
+ auto L = [](auto ... As) {
+ return [](auto b) ->decltype(b) {
+ vfun([](decltype(As) a) -> decltype(a) { return a; } ...)(FirstType<decltype(As)...>{});
+ return decltype(b){};
+ };
+ };
+ auto LL = L(1, 'a', 3.14, "abc");
+ LL("dim");
+ }
+ return 0;
+}
+int run = test();
+}
} // end ns nested_non_capturing_lambda_tests
OpenPOWER on IntegriCloud