summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/lambda-capture-pack.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-04 17:17:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-04 17:17:20 +0000
commit7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f (patch)
treec5eb10d1d4e1f82ebd3925ca1bde79d1145d73e3 /clang/test/SemaTemplate/lambda-capture-pack.cpp
parentf4302ad35e340f01529bf32919410b2577f899bd (diff)
downloadbcm5719-llvm-7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f.tar.gz
bcm5719-llvm-7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f.zip
PR42104: Support instantiations of lambdas that implicitly capture
packs. Two changes: * Track odr-use via FunctionParmPackExprs to properly handle dependent odr-uses of packs in generic lambdas. * Do not instantiate implicit captures; instead, regenerate them by instantiating the body of the lambda. This is necessary to distinguish between cases where only one element of a pack is captured and cases where the entire pack is captured. This reinstates r362358 (reverted in r362375) with a fix for an uninitialized variable use in UpdateMarkingForLValueToRValue. llvm-svn: 362531
Diffstat (limited to 'clang/test/SemaTemplate/lambda-capture-pack.cpp')
-rw-r--r--clang/test/SemaTemplate/lambda-capture-pack.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/lambda-capture-pack.cpp b/clang/test/SemaTemplate/lambda-capture-pack.cpp
new file mode 100644
index 00000000000..2fe576769db
--- /dev/null
+++ b/clang/test/SemaTemplate/lambda-capture-pack.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+template<typename ...T, typename ...Lambda> void check_sizes(Lambda ...L) {
+ static_assert(((sizeof(T) == sizeof(Lambda)) && ...));
+}
+
+template<typename ...T> void f(T ...v) {
+ // Pack expansion of lambdas: each lambda captures only one pack element.
+ check_sizes<T...>([=] { (void)&v; } ...);
+
+ // Pack expansion inside lambda: captures all pack elements.
+ auto l = [=] { ((void)&v, ...); };
+ static_assert(sizeof(l) >= (sizeof(T) + ...));
+}
+
+template void f(int, char, double);
OpenPOWER on IntegriCloud