diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-27 21:27:54 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-27 21:27:54 +0000 |
commit | c38498f0469aba6a0fb63d99ad398cdf788c5696 (patch) | |
tree | ed7df3fc6de1b03134e8350a770ac565f5824b60 /clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp | |
parent | 5b395243132dc3463c23daea1f215237565ce85f (diff) | |
download | bcm5719-llvm-c38498f0469aba6a0fb63d99ad398cdf788c5696.tar.gz bcm5719-llvm-c38498f0469aba6a0fb63d99ad398cdf788c5696.zip |
PR23334: Perform semantic checking of lambda capture initialization in the right context.
Previously we'd try to perform checks on the captures from the middle of
parsing the lambda's body, at the point where we detected that a variable
needed to be captured. This was wrong in a number of subtle ways. In
PR23334, we couldn't correctly handle the list of potential odr-uses
resulting from the capture, and our attempt to recover from that resulted
in a use-after-free.
We now defer building the initialization expression until we leave the lambda
body and return to the enclosing context, where the initialization does the
right thing. This patch only covers lambda-expressions, but we should apply
the same change to blocks and captured statements too.
llvm-svn: 235921
Diffstat (limited to 'clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp')
-rw-r--r-- | clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp index 90cbf02b2a6..c18bb7d1921 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp @@ -69,8 +69,7 @@ namespace p2 { template<typename T> struct Boom { Boom(const Boom&) { - T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \ - // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} + T* x = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} } void tickle() const; }; @@ -79,7 +78,7 @@ namespace p2 { void odr_used(R &r, Boom<T> boom) { const std::type_info &ti = typeid([=,&r] () -> R& { // expected-error{{lambda expression in an unevaluated operand}} - boom.tickle(); // expected-note{{in instantiation of member function}} + boom.tickle(); return r; }()); } |