diff options
author | James Dennett <jdennett@google.com> | 2015-05-07 18:48:18 +0000 |
---|---|---|
committer | James Dennett <jdennett@google.com> | 2015-05-07 18:48:18 +0000 |
commit | dd2ffea28893a3bb59c3e46baddec631bdc68462 (patch) | |
tree | f66a6fa469f57da65e4af75b9d5e1fcd86eb7b4f /clang/test | |
parent | 3d415cd2cd7949340c3cf181b8bd5780a9c32d91 (diff) | |
download | bcm5719-llvm-dd2ffea28893a3bb59c3e46baddec631bdc68462.tar.gz bcm5719-llvm-dd2ffea28893a3bb59c3e46baddec631bdc68462.zip |
Replace the broken LambdaCapture::isInitCapture API.
A LambdaCapture does not have sufficient information
to correctly determine whether it is an init-capture or not.
Doing so requires knowledge held in the LambdaExpr itself.
It the case of a nested capture of an init-capture it is not
sufficient to check (as LambdaCapture::isInitCapture did)
whether the associated VarDecl was from an init-capture.
This patch moves isInitCapture to LambdaExpr and updates
Capture->isInitCapture() to Lambda->isInitCapture(Capture).
llvm-svn: 236760
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/cxx1y-init-captures.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/cxx1y-init-captures.cpp b/clang/test/SemaCXX/cxx1y-init-captures.cpp index 64fe50a70e7..203e28d7c3f 100644 --- a/clang/test/SemaCXX/cxx1y-init-captures.cpp +++ b/clang/test/SemaCXX/cxx1y-init-captures.cpp @@ -166,4 +166,27 @@ int test(T t = T{}) { int run = test(); //expected-note {{instantiation}} -}
\ No newline at end of file +} + +namespace classification_of_captures_of_init_captures { + +template <typename T> +void f() { + [a = 24] () mutable { + [&a] { a = 3; }(); + }(); +} + +template <typename T> +void h() { + [a = 24] (auto param) mutable { + [&a] { a = 3; }(); + }(42); +} + +int run() { + f<int>(); + h<int>(); +} + +} |